/* tslint:disable */ /* eslint-disable */ /** * Sonatype Guide API * REST API into [Sonatype Guide](https://guide.sonatype.com). * * The version of the OpenAPI document: 202607 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { CumulativeCreditUsage, OssiUsageHistoryDTO, PeriodDTO, UsageDTO, } from '../models/index'; import { CumulativeCreditUsageFromJSON, CumulativeCreditUsageToJSON, OssiUsageHistoryDTOFromJSON, OssiUsageHistoryDTOToJSON, PeriodDTOFromJSON, PeriodDTOToJSON, UsageDTOFromJSON, UsageDTOToJSON, } from '../models/index'; export interface UsageApiGetCumulativeUsageRequest { startDate: Date; endDate: Date; } /** * */ export class UsageApi extends runtime.BaseAPI { /** * Retrieves all monthly credit periods from subscription start * Get credit periods */ async getCreditPeriodsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/usage/credit-periods`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PeriodDTOFromJSON)); } /** * Retrieves all monthly credit periods from subscription start * Get credit periods */ async getCreditPeriods(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const response = await this.getCreditPeriodsRaw(initOverrides); return await response.value(); } /** * Retrieves daily credit usage with cumulative totals and statistics for the specified billing period. Includes total credits used, daily average, peak day, and credit limit. Supports both FREE and PAID users. * Get cumulative credit usage for a billing period */ async getCumulativeUsageRaw(requestParameters: UsageApiGetCumulativeUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters['startDate'] == null) { throw new runtime.RequiredError( 'startDate', 'Required parameter "startDate" was null or undefined when calling getCumulativeUsage().' ); } if (requestParameters['endDate'] == null) { throw new runtime.RequiredError( 'endDate', 'Required parameter "endDate" was null or undefined when calling getCumulativeUsage().' ); } const queryParameters: any = {}; if (requestParameters['startDate'] != null) { queryParameters['startDate'] = (requestParameters['startDate'] as any).toISOString().substring(0,10); } if (requestParameters['endDate'] != null) { queryParameters['endDate'] = (requestParameters['endDate'] as any).toISOString().substring(0,10); } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/usage/cumulative`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Retrieves daily credit usage with cumulative totals and statistics for the specified billing period. Includes total credits used, daily average, peak day, and credit limit. Supports both FREE and PAID users. * Get cumulative credit usage for a billing period */ async getCumulativeUsage(requestParameters: UsageApiGetCumulativeUsageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.getCumulativeUsageRaw(requestParameters, initOverrides); } /** * Retrieves pre-migration OSSI API usage data aggregated by month. Shows estimated Guide credits based on historical unique component queries. Only available for OSSI-origin users. * Get historical OSSI usage */ async getOssiUsageHistoryRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/usage/ossi-history`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Retrieves pre-migration OSSI API usage data aggregated by month. Shows estimated Guide credits based on historical unique component queries. Only available for OSSI-origin users. * Get historical OSSI usage */ async getOssiUsageHistory(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.getOssiUsageHistoryRaw(initOverrides); } /** * Retrieves current credit usage and period information * Get usage information */ async getUsageRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer-jwt", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/usage`; const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UsageDTOFromJSON(jsonValue)); } /** * Retrieves current credit usage and period information * Get usage information */ async getUsage(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getUsageRaw(initOverrides); return await response.value(); } }