001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.http.remote;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.*;
017
018import java.io.*;
019import java.lang.annotation.*;
020
021import org.apache.juneau.annotation.*;
022import org.apache.juneau.http.annotation.*;
023
024/**
025 * Annotation applied to Java methods on REST proxy interface classes.
026 *
027 * <p>
028 * Note that this annotation is optional if you do not need to override any of the values.
029 *
030 * <h5 class='section'>See Also:</h5><ul>
031 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrc.Proxies">REST Proxies</a>
032 * </ul>
033 */
034@Documented
035@Target(METHOD)
036@Retention(RUNTIME)
037@Inherited
038@AnnotationGroup(RemoteOp.class)
039public @interface RemotePut {
040
041   /**
042    * REST service path.
043    *
044    * <p>
045    * If you do not specify a path, then the path is inferred from the Java method name.
046    *
047    * <h5 class='figure'>Example:</h5>
048    * <p class='bjava'>
049    *    <ja>@RemotePut</ja>
050    *    <jk>public void</jk> putPet(...);
051    * </p>
052    *
053    * <p>
054    * Note that you can also use {@link #value()} to specify the method name and path in shortened form.
055    *
056    * <ul class='values'>
057    *    <li>An absolute URL.
058    *    <li>A relative URL interpreted as relative to the root URL defined on the <c>RestClient</c> and/or {@link Remote#path()}.
059    *    <li>No path.
060    * </ul>
061    *
062    * @return The annotation value.
063    */
064   String path() default "";
065
066   /**
067    * The value the remote method returns.
068    *
069    * <ul class='values'>
070    *    <li>
071    *       {@link RemoteReturn#BODY} (default) - The body of the HTTP response converted to a POJO.
072    *       <br>The return type on the Java method can be any of the following:
073    *       <ul class='spaced-list'>
074    *          <li>
075    *             <jk>void</jk> - Don't parse any response.  Note that the method will still throw an exception if an
076    *             error HTTP status is returned.
077    *          <li>
078    *             Any parsable POJO - The body of the response will be converted to the POJO using the parser defined
079    *             on the <c>RestClient</c>.
080    *          <li>
081    *             Any POJO annotated with the {@link Response @Response} annotation.
082    *             This allows for response beans to be used which also allows for OpenAPI-based parsing and validation.
083    *          <li>
084    *             <c>HttpResponse</c> - Returns the raw <c>HttpResponse</c> returned by the inner
085    *             <c>HttpClient</c>.
086    *          <li>
087    *             {@link Reader} - Returns access to the raw reader of the response.
088    *          <li>
089    *             {@link InputStream} - Returns access to the raw input stream of the response.
090    *       </ul>
091    *    <li>
092    *       {@link RemoteReturn#STATUS} - The HTTP status code on the response.
093    *       <br>The return type on the Java method can be any of the following:
094    *       <ul>
095    *          <li><jk>int</jk>/<c>Integer</c> - The HTTP response code.
096    *          <li><jk>boolean</jk>/<c>Boolean</c> - <jk>true</jk> if the response code is <c>&lt;400</c>
097    *       </ul>
098    * </ul>
099    *
100    * @return The annotation value.
101    */
102   RemoteReturn returns() default RemoteReturn.BODY;
103
104   /**
105    * REST path.
106    *
107    * <p>
108    * Can be used to provide a shortened form for the {@link #path()} value.
109    *
110    * <p>
111    * The following examples are considered equivalent.
112    * <p class='bjava'>
113    *    <jc>// Normal form</jc>
114    *    <ja>@RemotePut</ja>(path=<js>"/{propertyName}"</js>)
115    *
116    *    <jc>// Shortened form</jc>
117    *    <ja>@RemotePut</ja>(<js>"/{propertyName}"</js>)
118    * </p>
119    *
120    * @return The annotation value.
121    */
122   String value() default "";
123}