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

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

Go to download

Builds the hapi fhir base. Requires Common lang, commons-text, and guava be built first.

There is a newer version: 7.0.2-r12
Show newest version
/*
 * #%L
 * HAPI FHIR - Core Library
 * %%
 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
 * %%
 * 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%
 */
package ca.uhn.fhir.rest.client.api;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.RequestFormatParamStyleEnum;
import ca.uhn.fhir.rest.api.SummaryEnum;
import jakarta.annotation.Nonnull;
import org.hl7.fhir.instance.model.api.IBaseResource;

public interface IRestfulClient {

	/**
	 * Sets the interfceptor service used by this client
	 *
	 * @since 3.8.0
	 */
	IInterceptorService getInterceptorService();

	/**
	 * Sets the interfceptor service used by this client
	 *
	 * @since 3.8.0
	 */
	void setInterceptorService(@Nonnull IInterceptorService theInterceptorService);

	/**
	 * 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 encoding that will be used on requests. Default is null, which means the client will not
	 * explicitly request an encoding. (This is standard behaviour according to the FHIR specification)
	 */
	EncodingEnum getEncoding();

	/**
	 * 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);

	/**
	 * 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.
	 * 

* This is a convenience method for performing the following call: * getInterceptorService().registerInterceptor(theInterceptor) *

*/ void registerInterceptor(Object theInterceptor); /** * 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 interceptor that was previously registered using {@link IRestfulClient#registerInterceptor(Object)}. *

* This is a convenience method for performing the following call: * getInterceptorService().unregisterInterceptor(theInterceptor) *

*/ void unregisterInterceptor(Object theInterceptor); /** * Configures what style of _format parameter should be used in requests */ void setFormatParamStyle(RequestFormatParamStyleEnum theRequestFormatParamStyle); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy