com.backblaze.b2.client.webApiClients.B2WebApiClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of b2-sdk-core Show documentation
Show all versions of b2-sdk-core Show documentation
The core logic for B2 SDK for Java. Does not include any implementations of B2WebApiClient.
/*
* Copyright 2017, Backblaze Inc. All Rights Reserved.
* License https://www.backblaze.com/using_b2_code.html
*/
package com.backblaze.b2.client.webApiClients;
import com.backblaze.b2.client.contentHandlers.B2ContentSink;
import com.backblaze.b2.client.contentSources.B2Headers;
import com.backblaze.b2.client.exceptions.B2Exception;
import java.io.InputStream;
import java.util.Map;
public interface B2WebApiClient extends AutoCloseable {
/**
* POSTs to a web service that takes JSON and returns JSON.
*
* @param url the url to post to
* @param headersOrNull if non-null, some headers to include in the post
* @param request the object to be converted to json (with B2Json) and posted as the body of the request
* @param responseClass the class to convert the response body into (with B2Json)
* @param the class
* @return the response object (converted from json by B2Json)
* @throws B2Exception if there's any trouble
*/
ResponseType postJsonReturnJson(
String url,
B2Headers headersOrNull,
Object request,
Class responseClass) throws B2Exception;
/**
* POSTs to a web service that takes content and returns JSON.
*
* @param url the url to post to
* @param headersOrNull if non-null, some headers to include in the post
* @param contentSource the content to post as the body of the request
* @param contentLength the number of bytes in the content to post
* @param responseClass the class to convert the response body into (with B2Json)
* @param the class
* @return the response object (converted from json by B2Json)
* @throws B2Exception if there's any trouble
*/
ResponseType postDataReturnJson(
String url,
B2Headers headersOrNull,
InputStream contentSource,
long contentLength,
Class responseClass) throws B2Exception;
/**
* GETs from a web service that returns content.
*
* @param url the url to post to
* @param headersOrNull if non-null, some headers to include in the post
* @param handler the object which will be called with the response's headers and content
* @throws B2Exception if there's any trouble
*/
void getContent(String url,
B2Headers headersOrNull,
B2ContentSink handler) throws B2Exception;
/**
* HEADSs to a web service that returns content, and returns the headers.
*
* @param url the url to head to
* @param headersOrNull the headers, if any.
* @return the headers of the response.
* @throws B2Exception if there's any trouble
*/
B2Headers head(String url, B2Headers headersOrNull) throws B2Exception;
/**
* Closes this object and its underlying resources.
* This is overridden from AutoCloseable to declare that it can't throw any exception.
*/
@Override
void close();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy