View Javadoc
1   package ca.uhn.fhir.rest.annotation;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 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 java.lang.annotation.ElementType;
24  import java.lang.annotation.Retention;
25  import java.lang.annotation.RetentionPolicy;
26  import java.lang.annotation.Target;
27  
28  import org.hl7.fhir.instance.model.api.IBaseResource;
29  
30  import ca.uhn.fhir.model.valueset.BundleTypeEnum;
31  
32  /**
33   * RESTful method annotation used for a method which provides FHIR "operations".
34   */
35  @Retention(RetentionPolicy.RUNTIME)
36  @Target(value = ElementType.METHOD)
37  public @interface Operation {
38  
39  	/**
40  	 * The name of the operation, e.g. "<code>$everything</code>" 
41  	 * 
42  	 * <p>
43  	 * This may be specified with or without a leading 
44  	 * '$'. (If the leading '$' is omitted, it will be added internally by the API).
45  	 * </p>
46  	 */
47  	String name();
48  
49  	/**
50  	 * On a client, this value should be populated with the resource type that the operation applies to. If set to
51  	 * {@link IBaseResource} (which is the default) than the operation applies to the server and not to a specific
52  	 * resource type.
53  	 * <p>
54  	 * This value has no effect when used on server implementations.
55  	 * </p>
56  	 */
57  	Class<? extends IBaseResource> type() default IBaseResource.class;
58  
59  	/**
60  	 * If a given operation method is <b><a href="http://en.wikipedia.org/wiki/Idempotence">idempotent</a></b>
61  	 * (meaning roughly that it does not modify any data or state on the server)
62  	 * then this flag should be set to <code>true</code> (default is <code>false</code>).
63  	 * <p>
64  	 * One the server, setting this to <code>true</code> means that the 
65  	 * server will allow the operation to be invoked using an <code>HTTP GET</code>
66  	 * (on top of the standard <code>HTTP POST</code>)
67  	 * </p> 
68  	 */
69  	boolean idempotent() default false;
70  
71  	/**
72  	 * This parameter may be used to specify the parts which will be found in the
73  	 * response to this operation.
74  	 */
75  	OperationParam[] returnParameters() default {};
76  	
77  	/**
78  	 * If this operation returns a bundle, this parameter can be used to specify the 
79  	 * bundle type to set in the bundle.
80  	 */
81  	BundleTypeEnum bundleType() default BundleTypeEnum.COLLECTION;
82  
83  }