001 002package ca.uhn.fhir.rest.api; 003 004/* 005 * #%L 006 * HAPI FHIR - Core Library 007 * %% 008 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * #L% 022 */ 023 024import java.util.HashMap; 025import java.util.Map; 026 027import ca.uhn.fhir.util.CoverageIgnore; 028import org.apache.commons.lang3.Validate; 029 030import javax.annotation.Nonnull; 031 032@CoverageIgnore 033public enum RestOperationTypeEnum { 034 035 BATCH("batch", true, false, false), 036 037 ADD_TAGS("add-tags", false, false, true), 038 039 DELETE_TAGS("delete-tags", false, false, true), 040 041 GET_TAGS("get-tags", false, true, true), 042 043 GET_PAGE("get-page", false, false, false), 044 045 /** 046 * <b> 047 * Use this value with caution, this may 048 * change as the GraphQL interface matures 049 * </b> 050 */ 051 GRAPHQL_REQUEST("graphql-request", false, false, false), 052 053 /** 054 * E.g. $everything, $validate, etc. 055 */ 056 EXTENDED_OPERATION_SERVER("extended-operation-server", false, false, false), 057 058 /** 059 * E.g. $everything, $validate, etc. 060 */ 061 EXTENDED_OPERATION_TYPE("extended-operation-type", false, false, false), 062 063 /** 064 * E.g. $everything, $validate, etc. 065 */ 066 EXTENDED_OPERATION_INSTANCE("extended-operation-instance", false, false, false), 067 068 /** 069 * Code Value: <b>create</b> 070 */ 071 CREATE("create", false, true, false), 072 073 /** 074 * Code Value: <b>delete</b> 075 */ 076 DELETE("delete", false, false, true), 077 078 /** 079 * Code Value: <b>history-instance</b> 080 */ 081 HISTORY_INSTANCE("history-instance", false, false, true), 082 083 /** 084 * Code Value: <b>history-system</b> 085 */ 086 HISTORY_SYSTEM("history-system", true, false, false), 087 088 /** 089 * Code Value: <b>history-type</b> 090 */ 091 HISTORY_TYPE("history-type", false, true, false), 092 093 /** 094 * Code Value: <b>read</b> 095 */ 096 READ("read", false, false, true), 097 098 /** 099 * Code Value: <b>search-system</b> 100 */ 101 SEARCH_SYSTEM("search-system", true, false, false), 102 103 /** 104 * Code Value: <b>search-type</b> 105 */ 106 SEARCH_TYPE("search-type", false, true, false), 107 108 /** 109 * Code Value: <b>transaction</b> 110 */ 111 TRANSACTION("transaction", true, false, false), 112 113 /** 114 * Code Value: <b>update</b> 115 */ 116 UPDATE("update", false, false, true), 117 118 /** 119 * Code Value: <b>validate</b> 120 */ 121 VALIDATE("validate", false, true, true), 122 123 /** 124 * Code Value: <b>vread</b> 125 */ 126 VREAD("vread", false, false, true), 127 128 /** 129 * Load the server's metadata 130 */ 131 METADATA("metadata", false, false, false), 132 133 /** 134 * $meta-add extended operation 135 */ 136 META_ADD("$meta-add", false, false, false), 137 138 /** 139 * $meta-add extended operation 140 */ 141 META("$meta", false, false, false), 142 143 /** 144 * $meta-delete extended operation 145 */ 146 META_DELETE("$meta-delete", false, false, false), 147 148 /** 149 * Patch operation 150 */ 151 PATCH("patch", false, false, true), 152 153 ; 154 155 private static final Map<String, RestOperationTypeEnum> CODE_TO_ENUM = new HashMap<String, RestOperationTypeEnum>(); 156 157 /** 158 * Identifier for this Value Set: http://hl7.org/fhir/vs/type-restful-operation 159 */ 160 public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/type-restful-operation"; 161 162 /** 163 * Name for this Value Set: RestfulOperationType 164 */ 165 public static final String VALUESET_NAME = "RestfulOperationType"; 166 167 static { 168 for (RestOperationTypeEnum next : RestOperationTypeEnum.values()) { 169 CODE_TO_ENUM.put(next.getCode(), next); 170 } 171 } 172 173 private final String myCode; 174 private final boolean mySystemLevel; 175 private final boolean myTypeLevel; 176 private final boolean myInstanceLevel; 177 178 /** 179 * Constructor 180 */ 181 RestOperationTypeEnum(@Nonnull String theCode, boolean theSystemLevel, boolean theTypeLevel, boolean theInstanceLevel) { 182 myCode = theCode; 183 mySystemLevel = theSystemLevel; 184 myTypeLevel = theTypeLevel; 185 myInstanceLevel = theInstanceLevel; 186 } 187 188 /** 189 * Returns the enumerated value associated with this code 190 */ 191 public RestOperationTypeEnum forCode(@Nonnull String theCode) { 192 Validate.notNull(theCode, "theCode must not be null"); 193 return CODE_TO_ENUM.get(theCode); 194 } 195 196 /** 197 * Returns the code associated with this enumerated value 198 */ 199 @Nonnull 200 public String getCode() { 201 return myCode; 202 } 203 204 public boolean isSystemLevel() { 205 return mySystemLevel; 206 } 207 208 public boolean isTypeLevel() { 209 return myTypeLevel; 210 } 211 212 public boolean isInstanceLevel() { 213 return myInstanceLevel; 214 } 215}