View Javadoc
1   package ca.uhn.fhir.rest.annotation;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2019 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.model.valueset.BundleTypeEnum;
24  import org.hl7.fhir.instance.model.api.IBaseResource;
25  
26  import java.lang.annotation.ElementType;
27  import java.lang.annotation.Retention;
28  import java.lang.annotation.RetentionPolicy;
29  import java.lang.annotation.Target;
30  
31  /**
32   * RESTful method annotation used for a method which provides FHIR "operations".
33   */
34  @Retention(RetentionPolicy.RUNTIME)
35  @Target(value = ElementType.METHOD)
36  public @interface Operation {
37  
38  	/**
39  	 * This constant is a special return value for {@link #name()}. If this name is
40  	 * used, the given operation method will match all operation calls. This is
41  	 * generally not desirable, but can be useful if you have a server that should
42  	 * dynamically match any FHIR operations that are requested.
43  	 */
44  	String NAME_MATCH_ALL = "*";
45  
46  	/**
47  	 * The name of the operation, e.g. "<code>$everything</code>"
48  	 *
49  	 * <p>
50  	 * This may be specified with or without a leading
51  	 * '$'. (If the leading '$' is omitted, it will be added internally by the API).
52  	 * </p>
53  	 */
54  	String name();
55  
56  	/**
57  	 * On a client, this value should be populated with the resource type that the operation applies to. If set to
58  	 * {@link IBaseResource} (which is the default) than the operation applies to the server and not to a specific
59  	 * resource type.
60  	 * <p>
61  	 * This value has no effect when used on server implementations.
62  	 * </p>
63  	 */
64  	Class<? extends IBaseResource> type() default IBaseResource.class;
65  
66  	/**
67  	 * If a given operation method is <b><a href="http://en.wikipedia.org/wiki/Idempotence">idempotent</a></b>
68  	 * (meaning roughly that it does not modify any data or state on the server)
69  	 * then this flag should be set to <code>true</code> (default is <code>false</code>).
70  	 * <p>
71  	 * One the server, setting this to <code>true</code> means that the
72  	 * server will allow the operation to be invoked using an <code>HTTP GET</code>
73  	 * (on top of the standard <code>HTTP POST</code>)
74  	 * </p>
75  	 */
76  	boolean idempotent() default false;
77  
78  	/**
79  	 * This parameter may be used to specify the parts which will be found in the
80  	 * response to this operation.
81  	 */
82  	OperationParam[] returnParameters() default {};
83  
84  	/**
85  	 * If this operation returns a bundle, this parameter can be used to specify the
86  	 * bundle type to set in the bundle.
87  	 */
88  	BundleTypeEnum bundleType() default BundleTypeEnum.COLLECTION;
89  
90  }