/** * Gravitee.io Portal Rest API * API dedicated to the devportal part of Gravitee * * The version of the OpenAPI document: 3.0.0 * Contact: contact@graviteesource.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams, HttpResponse, HttpEvent, HttpParameterCodec } from '@angular/common/http'; import { CustomHttpParameterCodec } from '../encoder'; import { Observable } from 'rxjs'; import { ErrorResponse } from '../model/errorResponse'; import { Key } from '../model/key'; import { Subscription } from '../model/subscription'; import { SubscriptionInput } from '../model/subscriptionInput'; import { SubscriptionsResponse } from '../model/subscriptionsResponse'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; export interface CloseSubscriptionRequestParams { subscriptionId: string; } export interface CreateSubscriptionRequestParams { SubscriptionInput?: SubscriptionInput; } export interface GetSubscriptionBuySubscriptionIdRequestParams { subscriptionId: string; include?: Array<'keys'>; } export interface GetSubscriptionsRequestParams { apiId?: string; applicationId?: string; page?: number; size?: number; } export interface RenewKeySubscriptionRequestParams { subscriptionId: string; request_body?: Array; } export interface RevokeKeySubscriptionRequestParams { subscriptionId: string; keyId: string; } @Injectable({ providedIn: 'root' }) export class SubscriptionService { protected basePath = 'http://demo.gravitee.io/portal/DEFAULT'; public defaultHeaders = new HttpHeaders(); public configuration = new Configuration(); public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { if (configuration) { this.configuration = configuration; } if (typeof this.configuration.basePath !== 'string') { if (typeof basePath !== 'string') { basePath = this.basePath; } this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } /** * Close a subscription * Close a subscription. User must have APPLICATION_SUBSCRIPTION[DELETE] permission. * @param requestParameters * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public closeSubscription(requestParameters: CloseSubscriptionRequestParams, observe?: 'body', reportProgress?: boolean): Observable; public closeSubscription(requestParameters: CloseSubscriptionRequestParams, observe?: 'response', reportProgress?: boolean): Observable>; public closeSubscription(requestParameters: CloseSubscriptionRequestParams, observe?: 'events', reportProgress?: boolean): Observable>; public closeSubscription(requestParameters: CloseSubscriptionRequestParams, observe: any = 'body', reportProgress: boolean = false ): Observable { const subscriptionId = requestParameters.subscriptionId; if (subscriptionId === null || subscriptionId === undefined) { throw new Error('Required parameter subscriptionId was null or undefined when calling closeSubscription.'); } let headers = this.defaultHeaders; // authentication (BasicAuth) required if (this.configuration.username || this.configuration.password) { headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } // authentication (CookieAuth) required // to determine the Accept header const httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.post(`${this.configuration.basePath}/subscriptions/${encodeURIComponent(String(subscriptionId))}/_close`, null, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Create a subscription. * Create a new subscription. User must have APPLICATION_SUBSCRIPTION[CREATE] permission. * @param requestParameters * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public createSubscription(requestParameters: CreateSubscriptionRequestParams, observe?: 'body', reportProgress?: boolean): Observable; public createSubscription(requestParameters: CreateSubscriptionRequestParams, observe?: 'response', reportProgress?: boolean): Observable>; public createSubscription(requestParameters: CreateSubscriptionRequestParams, observe?: 'events', reportProgress?: boolean): Observable>; public createSubscription(requestParameters: CreateSubscriptionRequestParams, observe: any = 'body', reportProgress: boolean = false ): Observable { const SubscriptionInput = requestParameters.SubscriptionInput; let headers = this.defaultHeaders; // authentication (BasicAuth) required if (this.configuration.username || this.configuration.password) { headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } // authentication (CookieAuth) required // to determine the Accept header const httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ 'application/json' ]; const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } return this.httpClient.post(`${this.configuration.basePath}/subscriptions`, SubscriptionInput, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Get a subscription. * Get a subscription. User must have API_SUBSCRIPTION[CREATE] or APPLICATION_SUBSCRIPTION[CREATE] permission. * @param requestParameters * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public getSubscriptionBuySubscriptionId(requestParameters: GetSubscriptionBuySubscriptionIdRequestParams, observe?: 'body', reportProgress?: boolean): Observable; public getSubscriptionBuySubscriptionId(requestParameters: GetSubscriptionBuySubscriptionIdRequestParams, observe?: 'response', reportProgress?: boolean): Observable>; public getSubscriptionBuySubscriptionId(requestParameters: GetSubscriptionBuySubscriptionIdRequestParams, observe?: 'events', reportProgress?: boolean): Observable>; public getSubscriptionBuySubscriptionId(requestParameters: GetSubscriptionBuySubscriptionIdRequestParams, observe: any = 'body', reportProgress: boolean = false ): Observable { const subscriptionId = requestParameters.subscriptionId; if (subscriptionId === null || subscriptionId === undefined) { throw new Error('Required parameter subscriptionId was null or undefined when calling getSubscriptionBuySubscriptionId.'); } const include = requestParameters.include; let queryParameters = new HttpParams({encoder: this.encoder}); if (include) { include.forEach((element) => { queryParameters = queryParameters.append('include', element); }) } let headers = this.defaultHeaders; // authentication (BasicAuth) required if (this.configuration.username || this.configuration.password) { headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } // authentication (CookieAuth) required // to determine the Accept header const httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.get(`${this.configuration.basePath}/subscriptions/${encodeURIComponent(String(subscriptionId))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * List all subscriptions, filtered by api and/or by application. At least an api or an application must be provided. User must have the APPLICATION_SUBSCRIPTION[READ] permission to list subscription with application query param.\\ User must have the API_SUBSCRIPTION[READ] permission to list subscription with api query param. * @param requestParameters * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public getSubscriptions(requestParameters: GetSubscriptionsRequestParams, observe?: 'body', reportProgress?: boolean): Observable; public getSubscriptions(requestParameters: GetSubscriptionsRequestParams, observe?: 'response', reportProgress?: boolean): Observable>; public getSubscriptions(requestParameters: GetSubscriptionsRequestParams, observe?: 'events', reportProgress?: boolean): Observable>; public getSubscriptions(requestParameters: GetSubscriptionsRequestParams, observe: any = 'body', reportProgress: boolean = false ): Observable { const apiId = requestParameters.apiId; const applicationId = requestParameters.applicationId; const page = requestParameters.page; const size = requestParameters.size; let queryParameters = new HttpParams({encoder: this.encoder}); if (apiId !== undefined && apiId !== null) { queryParameters = queryParameters.set('apiId', apiId); } if (applicationId !== undefined && applicationId !== null) { queryParameters = queryParameters.set('applicationId', applicationId); } if (page !== undefined && page !== null) { queryParameters = queryParameters.set('page', page); } if (size !== undefined && size !== null) { queryParameters = queryParameters.set('size', size); } let headers = this.defaultHeaders; // authentication (BasicAuth) required if (this.configuration.username || this.configuration.password) { headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } // authentication (CookieAuth) required // to determine the Accept header const httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.get(`${this.configuration.basePath}/subscriptions`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Renew a key subscription. * Renew a key subscription. User must have API_SUBSCRIPTION[UPDATE] or APPLICATION_SUBSCRIPTION[UPDATE] permission. * @param requestParameters * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public renewKeySubscription(requestParameters: RenewKeySubscriptionRequestParams, observe?: 'body', reportProgress?: boolean): Observable; public renewKeySubscription(requestParameters: RenewKeySubscriptionRequestParams, observe?: 'response', reportProgress?: boolean): Observable>; public renewKeySubscription(requestParameters: RenewKeySubscriptionRequestParams, observe?: 'events', reportProgress?: boolean): Observable>; public renewKeySubscription(requestParameters: RenewKeySubscriptionRequestParams, observe: any = 'body', reportProgress: boolean = false ): Observable { const subscriptionId = requestParameters.subscriptionId; if (subscriptionId === null || subscriptionId === undefined) { throw new Error('Required parameter subscriptionId was null or undefined when calling renewKeySubscription.'); } const request_body = requestParameters.request_body; let headers = this.defaultHeaders; // authentication (BasicAuth) required if (this.configuration.username || this.configuration.password) { headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } // authentication (CookieAuth) required // to determine the Accept header const httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } // to determine the Content-Type header const consumes: string[] = [ 'application/json' ]; const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); if (httpContentTypeSelected !== undefined) { headers = headers.set('Content-Type', httpContentTypeSelected); } return this.httpClient.post(`${this.configuration.basePath}/subscriptions/${encodeURIComponent(String(subscriptionId))}/keys/_renew`, request_body, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } /** * Revoke a key subscription. * Revoke a key subscription. User must have API_SUBSCRIPTION[UPDATE] or APPLICATION_SUBSCRIPTION[UPDATE] permission. * @param requestParameters * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public revokeKeySubscription(requestParameters: RevokeKeySubscriptionRequestParams, observe?: 'body', reportProgress?: boolean): Observable; public revokeKeySubscription(requestParameters: RevokeKeySubscriptionRequestParams, observe?: 'response', reportProgress?: boolean): Observable>; public revokeKeySubscription(requestParameters: RevokeKeySubscriptionRequestParams, observe?: 'events', reportProgress?: boolean): Observable>; public revokeKeySubscription(requestParameters: RevokeKeySubscriptionRequestParams, observe: any = 'body', reportProgress: boolean = false ): Observable { const subscriptionId = requestParameters.subscriptionId; if (subscriptionId === null || subscriptionId === undefined) { throw new Error('Required parameter subscriptionId was null or undefined when calling revokeKeySubscription.'); } const keyId = requestParameters.keyId; if (keyId === null || keyId === undefined) { throw new Error('Required parameter keyId was null or undefined when calling revokeKeySubscription.'); } let headers = this.defaultHeaders; // authentication (BasicAuth) required if (this.configuration.username || this.configuration.password) { headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password)); } // authentication (CookieAuth) required // to determine the Accept header const httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected !== undefined) { headers = headers.set('Accept', httpHeaderAcceptSelected); } return this.httpClient.post(`${this.configuration.basePath}/subscriptions/${encodeURIComponent(String(subscriptionId))}/keys/${encodeURIComponent(String(keyId))}/_revoke`, null, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } }