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