View Javadoc
1   package ca.uhn.fhir.rest.gclient;
2   
3   import ca.uhn.fhir.rest.api.CacheControlDirective;
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  
32  public interface IClientExecutable<T extends IClientExecutable<?, Y>, Y> {
33  
34  	/**
35  	 * If set to true, the client will log the request and response to the SLF4J logger. This can be useful for
36  	 * debugging, but is generally not desirable in a production situation.
37  	 *
38  	 * @deprecated Use the client logging interceptor to log requests and responses instead. See <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_client.html#req_resp_logging">here</a> for more information.
39  	 */
40  	@Deprecated
41  	T andLogRequestAndResponse(boolean theLogRequestAndResponse);
42  
43  	/**
44  	 * Sets the <code>Cache-Control</code> header value, which advises the server (or any cache in front of it)
45  	 * how to behave in terms of cached requests
46  	 */
47  	T cacheControl(CacheControlDirective theCacheControlDirective);
48  
49  	/**
50  	 * Request that the server return subsetted resources, containing only the elements specified in the given parameters.
51  	 * For example: <code>subsetElements("name", "identifier")</code> requests that the server only return
52  	 * the "name" and "identifier" fields in the returned resource, and omit any others.
53  	 */
54  	T elementsSubset(String... theElements);
55  
56  	/**
57  	 * Request that the server respond with JSON via the Accept header and possibly also the
58  	 * <code>_format</code> parameter if {@link ca.uhn.fhir.rest.client.api.IRestfulClient#setFormatParamStyle(RequestFormatParamStyleEnum) configured to do so}.
59  	 * <p>
60  	 * This method will have no effect if {@link #accept(String) a custom Accept header} is specified.
61  	 * </p>
62  	 *
63  	 * @see #accept(String)
64  	 */
65  	T encoded(EncodingEnum theEncoding);
66  
67  	/**
68  	 * Request that the server respond with JSON via the Accept header and possibly also the
69  	 * <code>_format</code> parameter if {@link ca.uhn.fhir.rest.client.api.IRestfulClient#setFormatParamStyle(RequestFormatParamStyleEnum) configured to do so}.
70  	 * <p>
71  	 * This method will have no effect if {@link #accept(String) a custom Accept header} is specified.
72  	 * </p>
73  	 *
74  	 * @see #accept(String)
75  	 * @see #encoded(EncodingEnum)
76  	 */
77  	T encodedJson();
78  
79  	/**
80  	 * Request that the server respond with JSON via the Accept header and possibly also the
81  	 * <code>_format</code> parameter if {@link ca.uhn.fhir.rest.client.api.IRestfulClient#setFormatParamStyle(RequestFormatParamStyleEnum) configured to do so}.
82  	 * <p>
83  	 * This method will have no effect if {@link #accept(String) a custom Accept header} is specified.
84  	 * </p>
85  	 *
86  	 * @see #accept(String)
87  	 * @see #encoded(EncodingEnum)
88  	 */
89  	T encodedXml();
90  
91  	/**
92  	 * Actually execute the client operation
93  	 */
94  	Y execute();
95  
96  	/**
97  	 * Explicitly specify a custom structure type to attempt to use when parsing the response. This
98  	 * is useful for invocations where the response is a Bundle/Parameters containing nested resources,
99  	 * and you want to use specific custom structures for those nested resources.
100 	 * <p>
101 	 * See <a href="https://jamesagnew.github.io/hapi-fhir/doc_extensions.html">Profiles and Extensions</a> for more information on using custom structures
102 	 * </p>
103 	 */
104 	T preferResponseType(Class<? extends IBaseResource> theType);
105 
106 	/**
107 	 * Explicitly specify a list of custom structure types to attempt to use (in order from most to
108 	 * least preferred) when parsing the response. This
109 	 * is useful for invocations where the response is a Bundle/Parameters containing nested resources,
110 	 * and you want to use specific custom structures for those nested resources.
111 	 * <p>
112 	 * See <a href="https://jamesagnew.github.io/hapi-fhir/doc_extensions.html">Profiles and Extensions</a> for more information on using custom structures
113 	 * </p>
114 	 */
115 	T preferResponseTypes(List<Class<? extends IBaseResource>> theTypes);
116 
117 	/**
118 	 * Request pretty-printed response via the <code>_pretty</code> parameter
119 	 */
120 	T prettyPrint();
121 
122 	/**
123 	 * Request that the server modify the response using the <code>_summary</code> param
124 	 */
125 	T summaryMode(SummaryEnum theSummary);
126 
127 	/**
128 	 * Specifies a custom <code>Accept</code> header that should be supplied with the
129 	 * request.
130 	 * <p>
131 	 * Note that this method overrides any encoding preferences specified with
132 	 * {@link #encodedJson()} or {@link #encodedXml()}. It is generally easier to
133 	 * just use those methods if you simply want to request a specific FHIR encoding.
134 	 * </p>
135 	 *
136 	 * @param theHeaderValue The header value, e.g. "application/fhir+json". Constants such
137 	 *                       as {@link ca.uhn.fhir.rest.api.Constants#CT_FHIR_XML_NEW} and
138 	 *                       {@link ca.uhn.fhir.rest.api.Constants#CT_FHIR_JSON_NEW} may
139 	 *                       be useful. If set to <code>null</code> or an empty string, the
140 	 *                       default Accept header will be used.
141 	 * @see #encoded(EncodingEnum)
142 	 * @see #encodedJson()
143 	 * @see #encodedXml()
144 	 */
145 	T accept(String theHeaderValue);
146 }