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