View Javadoc
1   package ca.uhn.fhir.rest.client.api;
2   
3   import ca.uhn.fhir.context.FhirContext;
4   import ca.uhn.fhir.rest.api.EncodingEnum;
5   import ca.uhn.fhir.rest.api.RequestFormatParamStyleEnum;
6   import ca.uhn.fhir.rest.api.SummaryEnum;
7   import org.hl7.fhir.instance.model.api.IBaseResource;
8   
9   import java.util.List;
10  
11  /*
12   * #%L
13   * HAPI FHIR - Core Library
14   * %%
15   * Copyright (C) 2014 - 2019 University Health Network
16   * %%
17   * Licensed under the Apache License, Version 2.0 (the "License");
18   * you may not use this file except in compliance with the License.
19   * You may obtain a copy of the License at
20   * 
21   * http://www.apache.org/licenses/LICENSE-2.0
22   * 
23   * Unless required by applicable law or agreed to in writing, software
24   * distributed under the License is distributed on an "AS IS" BASIS,
25   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26   * See the License for the specific language governing permissions and
27   * limitations under the License.
28   * #L%
29   */
30  
31  public interface IRestfulClient {
32  
33  	/**
34  	 * Retrieve the contents at the given URL and parse them as a resource. This
35  	 * method could be used as a low level implementation of a read/vread/search
36  	 * operation.
37  	 *
38  	 * @param theResourceType The resource type to parse
39  	 * @param theUrl          The URL to load
40  	 * @return The parsed resource
41  	 */
42  	<T extends IBaseResource> T fetchResourceFromUrl(Class<T> theResourceType, String theUrl);
43  
44  	/**
45  	 * Returns the encoding that will be used on requests. Default is <code>null</code>, which means the client will not
46  	 * explicitly request an encoding. (This is standard behaviour according to the FHIR specification)
47  	 */
48  	EncodingEnum getEncoding();
49  
50  	/**
51  	 * Specifies that the client should use the given encoding to do its
52  	 * queries. This means that the client will append the "_format" param
53  	 * to GET methods (read/search/etc), and will add an appropriate header for
54  	 * write methods.
55  	 *
56  	 * @param theEncoding The encoding to use in the request, or <code>null</code> not specify
57  	 *                    an encoding (which generally implies the use of XML). The default is <code>null</code>.
58  	 */
59  	void setEncoding(EncodingEnum theEncoding);
60  
61  	/**
62  	 * Returns the FHIR context associated with this client
63  	 */
64  	FhirContext getFhirContext();
65  
66  	/**
67  	 * Do not call this method in client code. It is a part of the internal HAPI API and
68  	 * is subject to change!
69  	 */
70  	IHttpClient getHttpClient();
71  
72  	/**
73  	 * Returns the client interceptors that have been registered with this client
74  	 */
75  	List<IClientInterceptor> getInterceptors();
76  
77  	/**
78  	 * Base URL for the server, with no trailing "/"
79  	 */
80  	String getServerBase();
81  
82  	/**
83  	 * Register a new interceptor for this client. An interceptor can be used to add additional
84  	 * logging, or add security headers, or pre-process responses, etc.
85  	 */
86  	void registerInterceptor(IClientInterceptor theInterceptor);
87  
88  	/**
89  	 * Specifies that the client should request that the server respond with "pretty printing"
90  	 * enabled. Note that this is a non-standard parameter, not all servers will
91  	 * support it.
92  	 *
93  	 * @param thePrettyPrint The pretty print flag to use in the request (default is <code>false</code>)
94  	 */
95  	void setPrettyPrint(Boolean thePrettyPrint);
96  
97  	/**
98  	 * If not set to <code>null</code>, specifies a value for the <code>_summary</code> parameter
99  	 * to be applied globally on this client.
100 	 */
101 	void setSummary(SummaryEnum theSummary);
102 
103 	/**
104 	 * Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
105 	 */
106 	void unregisterInterceptor(IClientInterceptor theInterceptor);
107 
108 	/**
109 	 * Configures what style of _format parameter should be used in requests
110 	 */
111 	void setFormatParamStyle(RequestFormatParamStyleEnum theRequestFormatParamStyle);
112 }