001package ca.uhn.fhir.rest.annotation; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2016 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 030/** 031 * RESTful method annotation used for a method which provides FHIR "operations". 032 */ 033@Retention(RetentionPolicy.RUNTIME) 034@Target(value = ElementType.METHOD) 035public @interface Operation { 036 037 /** 038 * The name of the operation, e.g. "<code>$everything</code>" 039 * 040 * <p> 041 * This may be specified with or without a leading 042 * '$'. (If the leading '$' is omitted, it will be added internally by the API). 043 * </p> 044 */ 045 String name(); 046 047 /** 048 * On a client, this value should be populated with the resource type that the operation applies to. If set to 049 * {@link IBaseResource} (which is the default) than the operation applies to the server and not to a specific 050 * resource type. 051 * <p> 052 * This value has no effect when used on server implementations. 053 * </p> 054 */ 055 Class<? extends IBaseResource> type() default IBaseResource.class; 056 057 /** 058 * If a given operation method is <b><a href="http://en.wikipedia.org/wiki/Idempotence">idempotent</a></b> 059 * (meaning roughly that it does not modify any data or state on the server) 060 * then this flag should be set to <code>true</code> (default is <code>false</code>). 061 * <p> 062 * One the server, setting this to <code>true</code> means that the 063 * server will allow the operation to be invoked using an <code>HTTP GET</code> 064 * (on top of the standard <code>HTTP POST</code>) 065 * </p> 066 */ 067 boolean idempotent() default false; 068 069 /** 070 * This parameter may be used to specify the parts which will be found in the 071 * response to this operation. 072 */ 073 OperationParam[] returnParameters() default {}; 074}