001package ca.uhn.fhir.rest.client.api; 002 003/*- 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 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 org.hl7.fhir.instance.model.api.IBaseBundle; 024import org.hl7.fhir.instance.model.api.IBaseResource; 025 026import ca.uhn.fhir.model.primitive.IdDt; 027import ca.uhn.fhir.model.primitive.UriDt; 028import ca.uhn.fhir.rest.api.MethodOutcome; 029import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException; 030import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException; 031import ca.uhn.fhir.rest.gclient.*; 032 033public interface IGenericClient extends IRestfulClient { 034 035 /** 036 * Fetch the capability statement for the server 037 */ 038 IFetchConformanceUntyped capabilities(); 039 040 /** 041 * Fluent method for the "create" operation, which creates a new resource instance on the server 042 */ 043 ICreate create(); 044 045 /** 046 * Fluent method for the "delete" operation, which performs a logical delete on a server resource 047 */ 048 IDelete delete(); 049 050 /** 051 * Retrieves the server's conformance statement 052 * 053 * @deprecated As of HAPI 3.0.0 this method has been deprecated, as the operation is now called "capabilities". Use {@link #capabilities()} instead 054 */ 055 IFetchConformanceUntyped fetchConformance(); 056 057 /** 058 * Force the client to fetch the server's conformance statement and validate that it is appropriate for this client. 059 * 060 * @throws FhirClientConnectionException 061 * if the conformance statement cannot be read, or if the client 062 * @throws FhirClientInappropriateForServerException 063 * If the conformance statement indicates that the server is inappropriate for this client (e.g. it implements the wrong version of FHIR) 064 */ 065 void forceConformanceCheck() throws FhirClientConnectionException; 066 067 /** 068 * Implementation of the "history" method 069 */ 070 IHistory history(); 071 072 /** 073 * Loads the previous/next bundle of resources from a paged set, using the link specified in the "link type=next" tag within the atom bundle. 074 */ 075 IGetPage loadPage(); 076 077 /** 078 * Fluent method for the "meta" operations, which can be used to get, add and remove tags and other 079 * Meta elements from a resource or across the server. 080 * 081 * @since 1.1 082 */ 083 IMeta meta(); 084 085 /** 086 * Implementation of the FHIR "extended operations" action 087 */ 088 IOperation operation(); 089 090 /** 091 * Fluent method for the "patch" operation, which performs a logical patch on a server resource 092 */ 093 IPatch patch(); 094 095 /** 096 * Fluent method for "read" and "vread" methods. 097 */ 098 IRead read(); 099 100 /** 101 * Implementation of the "instance read" method. 102 * 103 * @param theType 104 * The type of resource to load 105 * @param theId 106 * The ID to load 107 * @return The resource 108 * 109 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 110 */ 111 @Deprecated 112 <T extends IBaseResource> T read(Class<T> theType, String theId); 113 114 /** 115 * Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL. 116 * 117 * @param theType 118 * The resource type that is being retrieved 119 * @param theUrl 120 * The absolute URL, e.g. "http://example.com/fhir/Patient/123" 121 * @return The returned resource from the server 122 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 123 */ 124 @Deprecated 125 <T extends IBaseResource> T read(Class<T> theType, UriDt theUrl); 126 127 /** 128 * Perform the "read" operation (retrieve the latest version of a resource instance by ID) using an absolute URL. 129 * 130 * @param theUrl 131 * The absolute URL, e.g. "http://example.com/fhir/Patient/123" 132 * @return The returned resource from the server 133 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 134 */ 135 @Deprecated 136 IBaseResource read(UriDt theUrl); 137 138 /** 139 * Register a new interceptor for this client. An interceptor can be used to add additional logging, or add security headers, or pre-process responses, etc. 140 */ 141 @Override 142 void registerInterceptor(Object theInterceptor); 143 144 /** 145 * Search for resources matching a given set of criteria. Searching is a very powerful 146 * feature in FHIR with many features for specifying exactly what should be seaerched for 147 * and how it should be returned. See the <a href="http://www.hl7.org/fhir/search.html">specification on search</a> 148 * for more information. 149 */ 150 <T extends IBaseBundle> IUntypedQuery<T> search(); 151 152 /** 153 * If set to <code>true</code>, the client will log all requests and all responses. This is probably not a good production setting since it will result in a lot of extra logging, but it can be 154 * useful for troubleshooting. 155 * 156 * @param theLogRequestAndResponse 157 * Should requests and responses be logged 158 * @deprecated Use LoggingInterceptor as a client interceptor registered to your 159 * client instead, as this provides much more fine-grained control over what is logged. This 160 * method will be removed at some point (deprecated in HAPI 1.6 - 2016-06-16) 161 */ 162 @Deprecated 163 void setLogRequestAndResponse(boolean theLogRequestAndResponse); 164 165 /** 166 * Send a transaction (collection of resources) to the server to be executed as a single unit 167 */ 168 ITransaction transaction(); 169 170 /** 171 * Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(Object)} 172 */ 173 @Override 174 void unregisterInterceptor(Object theInterceptor); 175 176 /** 177 * Fluent method for the "update" operation, which updates a resource instance on the server 178 */ 179 IUpdate update(); 180 181 /** 182 * Implementation of the "instance update" method. 183 * 184 * @param theId 185 * The ID to update 186 * @param theResource 187 * The new resource body 188 * @return An outcome containing the results and possibly the new version ID 189 * @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 190 */ 191 @Deprecated 192 MethodOutcome update(IdDt theId, IBaseResource theResource); 193 194 /** 195 * Implementation of the "instance update" method. 196 * 197 * @param theId 198 * The ID to update 199 * @param theResource 200 * The new resource body 201 * @return An outcome containing the results and possibly the new version ID 202 * @deprecated Use {@link #update() update() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 203 */ 204 @Deprecated 205 MethodOutcome update(String theId, IBaseResource theResource); 206 207 /** 208 * Validate a resource 209 */ 210 IValidate validate(); 211 212 /** 213 * Implementation of the "type validate" method. 214 * 215 * @param theResource 216 * The resource to validate 217 * @return An outcome containing any validation issues 218 * @deprecated Use {@link #validate() validate() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 219 */ 220 @Deprecated 221 MethodOutcome validate(IBaseResource theResource); 222 223 /** 224 * Implementation of the "instance vread" method. Note that this method expects <code>theId</code> to contain a resource ID as well as a version ID, and will fail if it does not. 225 * <p> 226 * Note that if an absolute resource ID is passed in (i.e. a URL containing a protocol and host as well as the resource type and ID) the server base for the client will be ignored, and the URL 227 * passed in will be queried. 228 * </p> 229 * 230 * @param theType 231 * The type of resource to load 232 * @param theId 233 * The ID to load, including the resource ID and the resource version ID. Valid values include "Patient/123/_history/222", or "http://example.com/fhir/Patient/123/_history/222" 234 * @return The resource 235 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 236 */ 237 @Deprecated 238 <T extends IBaseResource> T vread(Class<T> theType, IdDt theId); 239 240 /** 241 * Implementation of the "instance vread" method. 242 * 243 * @param theType 244 * The type of resource to load 245 * @param theId 246 * The ID to load 247 * @param theVersionId 248 * The version ID 249 * @return The resource 250 * @deprecated Use {@link #read() read() fluent method} instead (deprecated in HAPI FHIR 3.0.0) 251 */ 252 @Deprecated 253 <T extends IBaseResource> T vread(Class<T> theType, String theId, String theVersionId); 254 255}