001package ca.uhn.fhir.rest.client.api; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2017 University Health Network 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 023 024import org.hl7.fhir.instance.model.api.IBaseResource; 025 026import ca.uhn.fhir.context.FhirContext; 027import ca.uhn.fhir.rest.api.SummaryEnum; 028import ca.uhn.fhir.rest.client.IClientInterceptor; 029import ca.uhn.fhir.rest.server.EncodingEnum; 030 031public interface IRestfulClient { 032 033 /** 034 * Retrieve the contents at the given URL and parse them as a resource. This 035 * method could be used as a low level implementation of a read/vread/search 036 * operation. 037 * 038 * @param theResourceType The resource type to parse 039 * @param theUrl The URL to load 040 * @return The parsed resource 041 */ 042 <T extends IBaseResource> T fetchResourceFromUrl(Class<T> theResourceType, String theUrl); 043 044 /** 045 * Returns the FHIR context associated with this client 046 */ 047 FhirContext getFhirContext(); 048 049 /** 050 * Do not call this method in client code. It is a part of the internal HAPI API and 051 * is subject to change! 052 */ 053 IHttpClient getHttpClient(); 054 055 /** 056 * Base URL for the server, with no trailing "/" 057 */ 058 String getServerBase(); 059 060 /** 061 * Register a new interceptor for this client. An interceptor can be used to add additional 062 * logging, or add security headers, or pre-process responses, etc. 063 */ 064 void registerInterceptor(IClientInterceptor theInterceptor); 065 066 /** 067 * Specifies that the client should use the given encoding to do its 068 * queries. This means that the client will append the "_format" param 069 * to GET methods (read/search/etc), and will add an appropriate header for 070 * write methods. 071 * 072 * @param theEncoding The encoding to use in the request, or <code>null</code> not specify 073 * an encoding (which generally implies the use of XML). The default is <code>null</code>. 074 */ 075 void setEncoding(EncodingEnum theEncoding); 076 077 /** 078 * Specifies that the client should request that the server respond with "pretty printing" 079 * enabled. Note that this is a non-standard parameter, not all servers will 080 * support it. 081 * 082 * @param thePrettyPrint The pretty print flag to use in the request (default is <code>false</code>) 083 */ 084 void setPrettyPrint(Boolean thePrettyPrint); 085 086 /** 087 * If not set to <code>null</code>, specifies a value for the <code>_summary</code> parameter 088 * to be applied globally on this client. 089 */ 090 void setSummary(SummaryEnum theSummary); 091 092 /** 093 * Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)} 094 */ 095 void unregisterInterceptor(IClientInterceptor theInterceptor); 096 097}