001package ca.uhn.fhir.rest.annotation;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2017 University Health Network
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.lang.annotation.ElementType;
024import java.lang.annotation.Retention;
025import java.lang.annotation.RetentionPolicy;
026import java.lang.annotation.Target;
027
028import org.hl7.fhir.instance.model.api.IBaseResource;
029
030import ca.uhn.fhir.model.valueset.BundleTypeEnum;
031
032/**
033 * RESTful method annotation used for a method which provides FHIR "operations".
034 */
035@Retention(RetentionPolicy.RUNTIME)
036@Target(value = ElementType.METHOD)
037public @interface Operation {
038
039        /**
040         * The name of the operation, e.g. "<code>$everything</code>" 
041         * 
042         * <p>
043         * This may be specified with or without a leading 
044         * '$'. (If the leading '$' is omitted, it will be added internally by the API).
045         * </p>
046         */
047        String name();
048
049        /**
050         * On a client, this value should be populated with the resource type that the operation applies to. If set to
051         * {@link IBaseResource} (which is the default) than the operation applies to the server and not to a specific
052         * resource type.
053         * <p>
054         * This value has no effect when used on server implementations.
055         * </p>
056         */
057        Class<? extends IBaseResource> type() default IBaseResource.class;
058
059        /**
060         * If a given operation method is <b><a href="http://en.wikipedia.org/wiki/Idempotence">idempotent</a></b>
061         * (meaning roughly that it does not modify any data or state on the server)
062         * then this flag should be set to <code>true</code> (default is <code>false</code>).
063         * <p>
064         * One the server, setting this to <code>true</code> means that the 
065         * server will allow the operation to be invoked using an <code>HTTP GET</code>
066         * (on top of the standard <code>HTTP POST</code>)
067         * </p> 
068         */
069        boolean idempotent() default false;
070
071        /**
072         * This parameter may be used to specify the parts which will be found in the
073         * response to this operation.
074         */
075        OperationParam[] returnParameters() default {};
076        
077        /**
078         * If this operation returns a bundle, this parameter can be used to specify the 
079         * bundle type to set in the bundle.
080         */
081        BundleTypeEnum bundleType() default BundleTypeEnum.COLLECTION;
082
083}