All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.uhn.fhir.rest.client.api.IRestfulClient Maven / Gradle / Ivy

There is a newer version: 7.6.1
Show newest version
package ca.uhn.fhir.rest.client.api;

/*
 * #%L
 * HAPI FHIR - Core Library
 * %%
 * Copyright (C) 2014 - 2016 University Health Network
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */


import org.hl7.fhir.instance.model.api.IBaseResource;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.SummaryEnum;
import ca.uhn.fhir.rest.client.IClientInterceptor;
import ca.uhn.fhir.rest.server.EncodingEnum;

public interface IRestfulClient {

	/**
	 * Retrieve the contents at the given URL and parse them as a resource. This
	 * method could be used as a low level implementation of a read/vread/search
	 * operation.
	 * 
	 * @param theResourceType The resource type to parse
	 * @param theUrl The URL to load
	 * @return The parsed resource
	 */
	 T fetchResourceFromUrl(Class theResourceType, String theUrl);
	
	/**
	 * Returns the FHIR context associated with this client
	 */
	FhirContext getFhirContext();
	
	/**
	 * Do not call this method in client code. It is a part of the internal HAPI API and 
	 * is subject to change!
	 */
	IHttpClient getHttpClient();
	
	/**
	 * Base URL for the server, with no trailing "/"
	 */
	String getServerBase();
	
	/**
	 * 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. 
	 */
	void registerInterceptor(IClientInterceptor theInterceptor);

	/**
	 * Specifies that the client should use the given encoding to do its 
	 * queries. This means that the client will append the "_format" param
	 * to GET methods (read/search/etc), and will add an appropriate header for
	 * write methods. 
	 * 
	 * @param theEncoding The encoding to use in the request, or null not specify
	 * an encoding (which generally implies the use of XML). The default is null.
	 */
	void setEncoding(EncodingEnum theEncoding);
	
	/**
	 * Specifies that the client should request that the server respond with "pretty printing"
	 * enabled. Note that this is a non-standard parameter, not all servers will
	 * support it.
	 * 
	 * @param thePrettyPrint The pretty print flag to use in the request (default is false)
	 */
	void setPrettyPrint(Boolean thePrettyPrint);

	/**
	 * If not set to null, specifies a value for the _summary parameter
	 * to be applied globally on this client.
	 */
	void setSummary(SummaryEnum theSummary);

	/**
	 * Remove an intercaptor that was previously registered using {@link IRestfulClient#registerInterceptor(IClientInterceptor)}
	 */
	void unregisterInterceptor(IClientInterceptor theInterceptor);
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy