
localhost.controllers.MetadataController Maven / Gradle / Ivy
/*
* RESTAPISDKLib
*
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/
package localhost.controllers;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import localhost.ApiHelper;
import localhost.AuthManager;
import localhost.Configuration;
import localhost.exceptions.ApiException;
import localhost.exceptions.ErrorResponseException;
import localhost.http.Headers;
import localhost.http.client.HttpCallback;
import localhost.http.client.HttpClient;
import localhost.http.client.HttpContext;
import localhost.http.request.HttpRequest;
import localhost.http.response.HttpResponse;
import localhost.http.response.HttpStringResponse;
import localhost.models.HomeLiveboardResponse;
import localhost.models.MetadataTagResponse;
import localhost.models.TspublicRestV2MetadataDependencyRequest;
import localhost.models.TspublicRestV2MetadataDetailSearchRequest;
import localhost.models.TspublicRestV2MetadataFavoriteAssignRequest;
import localhost.models.TspublicRestV2MetadataFavoriteUnassignRequest;
import localhost.models.TspublicRestV2MetadataHeaderSearchRequest;
import localhost.models.TspublicRestV2MetadataHomeliveboardAssignRequest;
import localhost.models.TspublicRestV2MetadataHomeliveboardUnassignRequest;
import localhost.models.TspublicRestV2MetadataTagAssignRequest;
import localhost.models.TspublicRestV2MetadataTagCreateRequest;
import localhost.models.TspublicRestV2MetadataTagUnassignRequest;
import localhost.models.TspublicRestV2MetadataTagUpdateRequest;
import localhost.models.TspublicRestV2MetadataTmlExportRequest;
import localhost.models.TspublicRestV2MetadataTmlImportRequest;
import localhost.models.Type8Enum;
import localhost.models.Type9Enum;
/**
* This class lists all the endpoints of the groups.
*/
public final class MetadataController extends BaseController {
/**
* Initializes the controller.
* @param config Configurations added in client.
* @param httpClient Send HTTP requests and read the responses.
* @param authManagers Apply authorization to requests.
*/
public MetadataController(Configuration config, HttpClient httpClient,
Map authManagers) {
super(config, httpClient, authManagers);
}
/**
* Initializes the controller with HTTPCallback.
* @param config Configurations added in client.
* @param httpClient Send HTTP requests and read the responses.
* @param authManagers Apply authorization to requests.
* @param httpCallback Callback to be called before and after the HTTP call.
*/
public MetadataController(Configuration config, HttpClient httpClient,
Map authManagers, HttpCallback httpCallback) {
super(config, httpClient, authManagers, httpCallback);
}
/**
* To get details of a specific tag, use this endpoint. At least one of id or name of tag is
* required. When both are given, then id will be considered.
* @param name Optional parameter: Name of the tag
* @param id Optional parameter: The GUID of the tag
* @return Returns the MetadataTagResponse response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public MetadataTagResponse getTag(
final String name,
final String id) throws ApiException, IOException {
HttpRequest request = buildGetTagRequest(name, id);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleGetTagResponse(context);
}
/**
* To get details of a specific tag, use this endpoint. At least one of id or name of tag is
* required. When both are given, then id will be considered.
* @param name Optional parameter: Name of the tag
* @param id Optional parameter: The GUID of the tag
* @return Returns the MetadataTagResponse response from the API call
*/
public CompletableFuture getTagAsync(
final String name,
final String id) {
return makeHttpCallAsync(() -> buildGetTagRequest(name, id),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleGetTagResponse(context));
}
/**
* Builds the HttpRequest object for getTag.
*/
private HttpRequest buildGetTagRequest(
final String name,
final String id) {
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/tag");
//load all query parameters
Map queryParameters = new HashMap<>();
queryParameters.put("name", name);
queryParameters.put("id", id);
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("Content-Type", config.getContentType());
headers.add("user-agent", BaseController.userAgent);
headers.add("accept", "application/json");
//prepare and invoke the API call request to fetch the response
HttpRequest request = getClientInstance().get(queryBuilder, headers, queryParameters,
null);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for getTag.
* @return An object of type MetadataTagResponse
*/
private MetadataTagResponse handleGetTagResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
MetadataTagResponse result = ApiHelper.deserialize(responseBody,
MetadataTagResponse.class);
return result;
}
/**
* To programmatically create tags, use this endpoint.
* @param body Required parameter: Example:
* @return Returns the MetadataTagResponse response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public MetadataTagResponse createTag(
final TspublicRestV2MetadataTagCreateRequest body) throws ApiException, IOException {
HttpRequest request = buildCreateTagRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleCreateTagResponse(context);
}
/**
* To programmatically create tags, use this endpoint.
* @param body Required parameter: Example:
* @return Returns the MetadataTagResponse response from the API call
*/
public CompletableFuture createTagAsync(
final TspublicRestV2MetadataTagCreateRequest body) {
return makeHttpCallAsync(() -> buildCreateTagRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleCreateTagResponse(context));
}
/**
* Builds the HttpRequest object for createTag.
*/
private HttpRequest buildCreateTagRequest(
final TspublicRestV2MetadataTagCreateRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/tag/create");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
headers.add("accept", "application/json");
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().postBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for createTag.
* @return An object of type MetadataTagResponse
*/
private MetadataTagResponse handleCreateTagResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
MetadataTagResponse result = ApiHelper.deserialize(responseBody,
MetadataTagResponse.class);
return result;
}
/**
* To programmatically update tags, use this endpoint. At least one of id or name of tag is
* required. When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean updateTag(
final TspublicRestV2MetadataTagUpdateRequest body) throws ApiException, IOException {
HttpRequest request = buildUpdateTagRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleUpdateTagResponse(context);
}
/**
* To programmatically update tags, use this endpoint. At least one of id or name of tag is
* required. When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture updateTagAsync(
final TspublicRestV2MetadataTagUpdateRequest body) {
return makeHttpCallAsync(() -> buildUpdateTagRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleUpdateTagResponse(context));
}
/**
* Builds the HttpRequest object for updateTag.
*/
private HttpRequest buildUpdateTagRequest(
final TspublicRestV2MetadataTagUpdateRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/tag/update");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for updateTag.
* @return An object of type boolean
*/
private Boolean handleUpdateTagResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To programmatically delete tags, use this endpoint. At least one of id or name of tag is
* required. When both are given, then id will be considered.
* @param name Optional parameter: Name of the tag
* @param id Optional parameter: The GUID of the tag
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean deleteTag(
final String name,
final String id) throws ApiException, IOException {
HttpRequest request = buildDeleteTagRequest(name, id);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleDeleteTagResponse(context);
}
/**
* To programmatically delete tags, use this endpoint. At least one of id or name of tag is
* required. When both are given, then id will be considered.
* @param name Optional parameter: Name of the tag
* @param id Optional parameter: The GUID of the tag
* @return Returns the Boolean response from the API call
*/
public CompletableFuture deleteTagAsync(
final String name,
final String id) {
return makeHttpCallAsync(() -> buildDeleteTagRequest(name, id),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleDeleteTagResponse(context));
}
/**
* Builds the HttpRequest object for deleteTag.
*/
private HttpRequest buildDeleteTagRequest(
final String name,
final String id) {
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/tag/delete");
//load all query parameters
Map queryParameters = new HashMap<>();
queryParameters.put("name", name);
queryParameters.put("id", id);
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("Content-Type", config.getContentType());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
HttpRequest request = getClientInstance().delete(queryBuilder, headers, queryParameters,
null);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for deleteTag.
* @return An object of type boolean
*/
private Boolean handleDeleteTagResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To programmatically assign tags to a metadata object, such as a liveboard, search answer,
* table, worksheet, or view, use this endpoint. At least one of id or name of tag is required.
* When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean assignTag(
final TspublicRestV2MetadataTagAssignRequest body) throws ApiException, IOException {
HttpRequest request = buildAssignTagRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleAssignTagResponse(context);
}
/**
* To programmatically assign tags to a metadata object, such as a liveboard, search answer,
* table, worksheet, or view, use this endpoint. At least one of id or name of tag is required.
* When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture assignTagAsync(
final TspublicRestV2MetadataTagAssignRequest body) {
return makeHttpCallAsync(() -> buildAssignTagRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleAssignTagResponse(context));
}
/**
* Builds the HttpRequest object for assignTag.
*/
private HttpRequest buildAssignTagRequest(
final TspublicRestV2MetadataTagAssignRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/tag/assign");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for assignTag.
* @return An object of type boolean
*/
private Boolean handleAssignTagResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To programmatically unassign tags to a metadata object, such as a liveboard, search answer,
* table, worksheet, or view, use this endpoint. At least one of id or name of tag is required.
* When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean unassignTag(
final TspublicRestV2MetadataTagUnassignRequest body) throws ApiException, IOException {
HttpRequest request = buildUnassignTagRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleUnassignTagResponse(context);
}
/**
* To programmatically unassign tags to a metadata object, such as a liveboard, search answer,
* table, worksheet, or view, use this endpoint. At least one of id or name of tag is required.
* When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture unassignTagAsync(
final TspublicRestV2MetadataTagUnassignRequest body) {
return makeHttpCallAsync(() -> buildUnassignTagRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleUnassignTagResponse(context));
}
/**
* Builds the HttpRequest object for unassignTag.
*/
private HttpRequest buildUnassignTagRequest(
final TspublicRestV2MetadataTagUnassignRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/tag/unassign");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for unassignTag.
* @return An object of type boolean
*/
private Boolean handleUnassignTagResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To programmatically assign objects to favorites for a given user account, use this endpoint.
* At least one of user id or username is required. When both are given, then id will be
* considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean assignFavorite(
final TspublicRestV2MetadataFavoriteAssignRequest body) throws ApiException, IOException {
HttpRequest request = buildAssignFavoriteRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleAssignFavoriteResponse(context);
}
/**
* To programmatically assign objects to favorites for a given user account, use this endpoint.
* At least one of user id or username is required. When both are given, then id will be
* considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture assignFavoriteAsync(
final TspublicRestV2MetadataFavoriteAssignRequest body) {
return makeHttpCallAsync(() -> buildAssignFavoriteRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleAssignFavoriteResponse(context));
}
/**
* Builds the HttpRequest object for assignFavorite.
*/
private HttpRequest buildAssignFavoriteRequest(
final TspublicRestV2MetadataFavoriteAssignRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/favorite/assign");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for assignFavorite.
* @return An object of type boolean
*/
private Boolean handleAssignFavoriteResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To programmatically unassign objects to favorites for a given user account, use this
* endpoint. At least one of user id or username is required. When both are given, then id will
* be considered. Screen reader support enabled.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean unassignFavorite(
final TspublicRestV2MetadataFavoriteUnassignRequest body) throws ApiException, IOException {
HttpRequest request = buildUnassignFavoriteRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleUnassignFavoriteResponse(context);
}
/**
* To programmatically unassign objects to favorites for a given user account, use this
* endpoint. At least one of user id or username is required. When both are given, then id will
* be considered. Screen reader support enabled.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture unassignFavoriteAsync(
final TspublicRestV2MetadataFavoriteUnassignRequest body) {
return makeHttpCallAsync(() -> buildUnassignFavoriteRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleUnassignFavoriteResponse(context));
}
/**
* Builds the HttpRequest object for unassignFavorite.
*/
private HttpRequest buildUnassignFavoriteRequest(
final TspublicRestV2MetadataFavoriteUnassignRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/favorite/unassign");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for unassignFavorite.
* @return An object of type boolean
*/
private Boolean handleUnassignFavoriteResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To get the name and id of liveboard that is set as a home liveboard for a user, use this
* endpoint. At least one of user id or username is required. When both are given, then id will
* be considered.
* @param userName Optional parameter: Example:
* @param userId Optional parameter: The GUID of the user
* @return Returns the HomeLiveboardResponse response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public HomeLiveboardResponse getHomeLiveboard(
final String userName,
final String userId) throws ApiException, IOException {
HttpRequest request = buildGetHomeLiveboardRequest(userName, userId);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleGetHomeLiveboardResponse(context);
}
/**
* To get the name and id of liveboard that is set as a home liveboard for a user, use this
* endpoint. At least one of user id or username is required. When both are given, then id will
* be considered.
* @param userName Optional parameter: Example:
* @param userId Optional parameter: The GUID of the user
* @return Returns the HomeLiveboardResponse response from the API call
*/
public CompletableFuture getHomeLiveboardAsync(
final String userName,
final String userId) {
return makeHttpCallAsync(() -> buildGetHomeLiveboardRequest(userName, userId),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleGetHomeLiveboardResponse(context));
}
/**
* Builds the HttpRequest object for getHomeLiveboard.
*/
private HttpRequest buildGetHomeLiveboardRequest(
final String userName,
final String userId) {
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/homeliveboard");
//load all query parameters
Map queryParameters = new HashMap<>();
queryParameters.put("userName", userName);
queryParameters.put("userId", userId);
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("Content-Type", config.getContentType());
headers.add("user-agent", BaseController.userAgent);
headers.add("accept", "application/json");
//prepare and invoke the API call request to fetch the response
HttpRequest request = getClientInstance().get(queryBuilder, headers, queryParameters,
null);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for getHomeLiveboard.
* @return An object of type HomeLiveboardResponse
*/
private HomeLiveboardResponse handleGetHomeLiveboardResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
HomeLiveboardResponse result = ApiHelper.deserialize(responseBody,
HomeLiveboardResponse.class);
return result;
}
/**
* To assign a specific liveboard as a home liveboard for a user, use this endpoint. At least
* one of user id or username is required. When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean assignHomeLiveboard(
final TspublicRestV2MetadataHomeliveboardAssignRequest body) throws ApiException, IOException {
HttpRequest request = buildAssignHomeLiveboardRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleAssignHomeLiveboardResponse(context);
}
/**
* To assign a specific liveboard as a home liveboard for a user, use this endpoint. At least
* one of user id or username is required. When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture assignHomeLiveboardAsync(
final TspublicRestV2MetadataHomeliveboardAssignRequest body) {
return makeHttpCallAsync(() -> buildAssignHomeLiveboardRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleAssignHomeLiveboardResponse(context));
}
/**
* Builds the HttpRequest object for assignHomeLiveboard.
*/
private HttpRequest buildAssignHomeLiveboardRequest(
final TspublicRestV2MetadataHomeliveboardAssignRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/homeliveboard/assign");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for assignHomeLiveboard.
* @return An object of type boolean
*/
private Boolean handleAssignHomeLiveboardResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To unassign the home liveboard set for a user, use this endpoint. At least one of user id or
* username is required. When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Boolean unassignHomeLiveboard(
final TspublicRestV2MetadataHomeliveboardUnassignRequest body) throws ApiException, IOException {
HttpRequest request = buildUnassignHomeLiveboardRequest(body);
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleUnassignHomeLiveboardResponse(context);
}
/**
* To unassign the home liveboard set for a user, use this endpoint. At least one of user id or
* username is required. When both are given, then id will be considered.
* @param body Required parameter: Example:
* @return Returns the Boolean response from the API call
*/
public CompletableFuture unassignHomeLiveboardAsync(
final TspublicRestV2MetadataHomeliveboardUnassignRequest body) {
return makeHttpCallAsync(() -> buildUnassignHomeLiveboardRequest(body),
req -> authManagers.get("global").applyAsync(req)
.thenCompose(request -> getClientInstance()
.executeAsync(request, false)),
context -> handleUnassignHomeLiveboardResponse(context));
}
/**
* Builds the HttpRequest object for unassignHomeLiveboard.
*/
private HttpRequest buildUnassignHomeLiveboardRequest(
final TspublicRestV2MetadataHomeliveboardUnassignRequest body) throws JsonProcessingException {
//validating required parameters
if (null == body) {
throw new NullPointerException("The parameter \"body\" is a required parameter and cannot be null.");
}
//the base uri for api requests
String baseUri = config.getBaseUri();
//prepare query string for API call
final StringBuilder queryBuilder = new StringBuilder(baseUri
+ "/tspublic/rest/v2/metadata/homeliveboard/unassign");
//load all headers for the outgoing API request
Headers headers = new Headers();
headers.add("Content-Type", "application/json");
headers.add("X-Requested-By", config.getXRequestedBy());
headers.add("Accept-Language", config.getAcceptLanguage());
headers.add("user-agent", BaseController.userAgent);
//prepare and invoke the API call request to fetch the response
String bodyJson = ApiHelper.serialize(body);
HttpRequest request = getClientInstance().putBody(queryBuilder, headers, null, bodyJson);
// Invoke the callback before request if its not null
if (getHttpCallback() != null) {
getHttpCallback().onBeforeRequest(request);
}
return request;
}
/**
* Processes the response for unassignHomeLiveboard.
* @return An object of type boolean
*/
private Boolean handleUnassignHomeLiveboardResponse(
HttpContext context) throws ApiException, IOException {
HttpResponse response = context.getResponse();
//invoke the callback after response if its not null
if (getHttpCallback() != null) {
getHttpCallback().onAfterResponse(context);
}
//Error handling using HTTP status codes
int responseCode = response.getStatusCode();
if (responseCode == 500) {
throw new ErrorResponseException("Operation failed or unauthorized request", context);
}
//handle errors defined at the API level
validateResponse(response, context);
//extract result from the http response
String responseBody = ((HttpStringResponse) response).getBody();
boolean result = Boolean.parseBoolean(responseBody);
return result;
}
/**
* To get a list of objects with incomplete metadata, use this endpoint.
* @return Returns the Object response from the API call
* @throws ApiException Represents error response from the server.
* @throws IOException Signals that an I/O exception of some sort has occurred.
*/
public Object getIncompleteObjects() throws ApiException, IOException {
HttpRequest request = buildGetIncompleteObjectsRequest();
authManagers.get("global").apply(request);
HttpResponse response = getClientInstance().execute(request, false);
HttpContext context = new HttpContext(request, response);
return handleGetIncompleteObjectsResponse(context);
}
/**
* To get a list of objects with incomplete metadata, use this endpoint.
* @return Returns the Object response from the API call
*/
public CompletableFuture
© 2015 - 2025 Weber Informatics LLC | Privacy Policy