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

com.seeq.api.UsageApi Maven / Gradle / Ivy

There is a newer version: 66.0.0-v202407310200
Show newest version
package com.seeq.api;

import com.seeq.ApiException;
import com.seeq.ApiClient;
import com.seeq.Configuration;
import com.seeq.model.*;
import com.seeq.Pair;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.ProcessingException;

import com.seeq.model.UsageOutputListV1;
import com.seeq.model.UsageTypesV1;


  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;

  public class UsageApi {
  private ApiClient apiClient;
  private long retryTimeout = 5_000; // Default of 5 seconds

  public UsageApi() {
  this(Configuration.getDefaultApiClient());
  }

  public UsageApi(ApiClient apiClient) {
  this.apiClient = apiClient;
  }

  public void setRetryTimeout(long retryTimeout) {
    this.retryTimeout = retryTimeout;
  }

  public long getRetryTimeout() {
    return this.retryTimeout;
  }

  public ApiClient getApiClient() {
  return apiClient;
  }

  public void setApiClient(ApiClient apiClient) {
  this.apiClient = apiClient;
  }

    /**
    * Get the list of available types that can be used as filter values for the reporting endpoint
    * 
      * @return UsageTypesV1
    * @throws ApiException if fails to make API call
    */
    public UsageTypesV1 getTypes() throws ApiException {
        ApiClient.ApiResponse localVarResponse = getTypesWithHttpInfo();
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Get the list of available types that can be used as filter values for the reporting endpoint
    * 
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getTypesWithHttpInfo() throws ApiException {
    Object localVarPostBody = null;
    // create path and map variables
    String localVarPath = "/usage/types";

    // query params
    List localVarQueryParams = new ArrayList();
    Map localVarHeaderParams = new HashMap();
    Map localVarFormParams = new HashMap();


    
    
      final String[] localVarAccepts = {
    "application/vnd.seeq.v1+json"
      };
      final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

      final String[] localVarContentTypes = {
    
      };
      final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

      String[] localVarAuthNames = new String[] { "api_key" };

      long apiClientInvocationTime = System.currentTimeMillis();
      while(true) {
        try {
        GenericType localVarReturnType = new GenericType() {};
        return apiClient.invokeAPIWithHttpInfo(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
          // Possible exceptions:
          // ===================
          // * ResponseProcessingException - in case processing of a received HTTP response fails (e.g. in a filter or
          //    during conversion of the response entity data to an instance of a particular Java type).
          // * ProcessingException - in case the request processing or subsequent I/O operation fails.
          // * WebApplicationException - in case the response status code of the response returned by the server is not
          //    successful and the specified response type is not Response.
          // * ApiException for exceptions wrapped by ApiClient. Most likely all WebApplicationException are wrapped
          //    in ApiException(s)
        } catch (ApiException | ProcessingException e) {
          if (e instanceof ProcessingException || e instanceof ApiException && ((ApiException) e).getCode() == 504) {
            long elapsedTime = System.currentTimeMillis() - apiClientInvocationTime;
            if (elapsedTime <= this.retryTimeout && this.retryTimeout != 0) {
              continue;
            }
          }
          throw e;
        }
      } // while
      }
    /**
    * Get usage records for the specified time range. Results will be sorted by date if aggregating by day or month, otherwise by amount descending and limited to the first 500 records
    * 
      * @param startTime Start time for the time frame (YYYY-MM-DDThh:mm:ss±hh:mm) (required)
      * @param endTime End time for the time frame (YYYY-MM-DDThh:mm:ss±hh:mm) (required)
      * @param type Filter by type of usage (e.g. Analysis, Screenshot) (optional)
      * @param source Filter by any part of the origin label or origin url fields (optional)
      * @param unit Filter by the unit that the usage is measured in (e.g. Bytes, Credits, Any). Default is Bytes. (optional, default to Bytes)
      * @param identityId Filter by the UUID of the user who initiated the request (optional)
      * @param aggregateBy Aggregate the usage records by one or more fields. Cannot aggregate by both Day and Month at the same time. (optional)
      * @return UsageOutputListV1
    * @throws ApiException if fails to make API call
    */
    public UsageOutputListV1 getUsage(String startTime, String endTime, List type, String source, String unit, List identityId, List aggregateBy) throws ApiException {
        ApiClient.ApiResponse localVarResponse = getUsageWithHttpInfo(startTime, endTime, type, source, unit, identityId, aggregateBy);
        return localVarResponse != null ? localVarResponse.getData() : null;
    }
    
    /**
    * Get usage records for the specified time range. Results will be sorted by date if aggregating by day or month, otherwise by amount descending and limited to the first 500 records
    * 
      * @param startTime Start time for the time frame (YYYY-MM-DDThh:mm:ss±hh:mm) (required)
      * @param endTime End time for the time frame (YYYY-MM-DDThh:mm:ss±hh:mm) (required)
      * @param type Filter by type of usage (e.g. Analysis, Screenshot) (optional)
      * @param source Filter by any part of the origin label or origin url fields (optional)
      * @param unit Filter by the unit that the usage is measured in (e.g. Bytes, Credits, Any). Default is Bytes. (optional, default to Bytes)
      * @param identityId Filter by the UUID of the user who initiated the request (optional)
      * @param aggregateBy Aggregate the usage records by one or more fields. Cannot aggregate by both Day and Month at the same time. (optional)
    * @throws ApiException if fails to make API call
    */
    public ApiClient.ApiResponse getUsageWithHttpInfo(String startTime, String endTime, List type, String source, String unit, List identityId, List aggregateBy) throws ApiException {
    Object localVarPostBody = null;
      // verify the required parameter 'startTime' is set
      if (startTime == null) {
      throw new ApiException(400, "Missing the required parameter 'startTime' when calling getUsage");
      }
      // verify the required parameter 'endTime' is set
      if (endTime == null) {
      throw new ApiException(400, "Missing the required parameter 'endTime' when calling getUsage");
      }
    // create path and map variables
    String localVarPath = "/usage";

    // query params
    List localVarQueryParams = new ArrayList();
    Map localVarHeaderParams = new HashMap();
    Map localVarFormParams = new HashMap();

      localVarQueryParams.addAll(apiClient.parameterToPairs("", "startTime", startTime));
      localVarQueryParams.addAll(apiClient.parameterToPairs("", "endTime", endTime));
      localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "type", type));
      localVarQueryParams.addAll(apiClient.parameterToPairs("", "source", source));
      localVarQueryParams.addAll(apiClient.parameterToPairs("", "unit", unit));
      localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "identityId", identityId));
      localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "aggregateBy", aggregateBy));

    
    
      final String[] localVarAccepts = {
    "application/vnd.seeq.v1+json"
      };
      final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

      final String[] localVarContentTypes = {
    
      };
      final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

      String[] localVarAuthNames = new String[] { "api_key" };

      long apiClientInvocationTime = System.currentTimeMillis();
      while(true) {
        try {
        GenericType localVarReturnType = new GenericType() {};
        return apiClient.invokeAPIWithHttpInfo(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
          // Possible exceptions:
          // ===================
          // * ResponseProcessingException - in case processing of a received HTTP response fails (e.g. in a filter or
          //    during conversion of the response entity data to an instance of a particular Java type).
          // * ProcessingException - in case the request processing or subsequent I/O operation fails.
          // * WebApplicationException - in case the response status code of the response returned by the server is not
          //    successful and the specified response type is not Response.
          // * ApiException for exceptions wrapped by ApiClient. Most likely all WebApplicationException are wrapped
          //    in ApiException(s)
        } catch (ApiException | ProcessingException e) {
          if (e instanceof ProcessingException || e instanceof ApiException && ((ApiException) e).getCode() == 504) {
            long elapsedTime = System.currentTimeMillis() - apiClientInvocationTime;
            if (elapsedTime <= this.retryTimeout && this.retryTimeout != 0) {
              continue;
            }
          }
          throw e;
        }
      } // while
      }
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy