View Javadoc
1   package ca.uhn.fhir.rest.client.api;
2   
3   /*-
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import org.hl7.fhir.instance.model.api.IBaseBundle;
24  import org.hl7.fhir.instance.model.api.IBaseResource;
25  
26  import ca.uhn.fhir.model.primitive.IdDt;
27  import ca.uhn.fhir.model.primitive.UriDt;
28  import ca.uhn.fhir.rest.api.MethodOutcome;
29  import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
30  import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException;
31  import ca.uhn.fhir.rest.gclient.*;
32  
33  public interface IGenericClient extends IRestfulClient {
34  
35  	/**
36  	 * Fetch the capability statement for the server
37  	 */
38  	IFetchConformanceUntyped capabilities();
39  
40  	/**
41  	 * Fluent method for the "create" operation, which creates a new resource instance on the server
42  	 */
43  	ICreate create();
44  
45  	/**
46  	 * Fluent method for the "delete" operation, which performs a logical delete on a server resource
47  	 */
48  	IDelete delete();
49  
50  	/**
51  	 * Retrieves the server's conformance statement
52  	 * 
53  	 * @deprecated As of HAPI 3.0.0 this method has been deprecated, as the operation is now called "capabilities". Use {@link #capabilities()} instead
54  	 */
55  	IFetchConformanceUntyped fetchConformance();
56  
57  	/**
58  	 * Force the client to fetch the server's conformance statement and validate that it is appropriate for this client.
59  	 * 
60  	 * @throws FhirClientConnectionException
61  	 *            if the conformance statement cannot be read, or if the client
62  	 * @throws FhirClientInappropriateForServerException
63  	 *            If the conformance statement indicates that the server is inappropriate for this client (e.g. it implements the wrong version of FHIR)
64  	 */
65  	void forceConformanceCheck() throws FhirClientConnectionException;
66  
67  	/**
68  	 * Implementation of the "history" method
69  	 */
70  	IHistory history();
71  
72  	/**
73  	 * 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.
74  	 */
75  	IGetPage loadPage();
76  
77  	/**
78  	 * Fluent method for the "meta" operations, which can be used to get, add and remove tags and other
79  	 * Meta elements from a resource or across the server.
80  	 * 
81  	 * @since 1.1
82  	 */
83  	IMeta meta();
84  
85  	/**
86  	 * Implementation of the FHIR "extended operations" action
87  	 */
88  	IOperation operation();
89  
90  	/**
91  	 * Fluent method for the "patch" operation, which performs a logical patch on a server resource
92  	 */
93  	IPatch patch();
94  
95  	/**
96  	 * Fluent method for "read" and "vread" methods.
97  	 */
98  	IRead read();
99  
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(IClientInterceptor 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(IClientInterceptor)}
172 	 */
173 	@Override
174 	void unregisterInterceptor(IClientInterceptor theInterceptor);
175 
176 	/**
177 	 * Fluent method for the "update" operation, which performs a logical delete on a server resource
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 }