From d9fb78fda70f3476d1a6850f9c1135b66c18882a Mon Sep 17 00:00:00 2001 From: Sammy <97321746+schaoukicoveo@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:32:31 -0400 Subject: [PATCH] feat: add new attributes to api key model (#857) * feat: add new attributes to api key model J:ORG-666 * chore: apply pr comments * chore: fix pr build * Update ApiKeysInterfaces.ts Co-authored-by: Frederic Beaudoin * Update ApiKeysInterfaces.ts Co-authored-by: Frederic Beaudoin * Update ApiKeysInterfaces.ts Co-authored-by: Frederic Beaudoin * Update Enums.ts Co-authored-by: Frederic Beaudoin * chore: apply pr comments --------- Co-authored-by: Frederic Beaudoin --- src/resources/ApiKeys/ApiKeys.ts | 2 +- src/resources/ApiKeys/ApiKeysInterfaces.ts | 18 +++++++++++++++--- src/resources/Enums.ts | 9 +++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/resources/ApiKeys/ApiKeys.ts b/src/resources/ApiKeys/ApiKeys.ts index ecf4925d5..693238337 100644 --- a/src/resources/ApiKeys/ApiKeys.ts +++ b/src/resources/ApiKeys/ApiKeys.ts @@ -10,7 +10,7 @@ export default class ApiKey extends Resource { return this.api.get(ApiKey.baseUrl); } - create(apiKey: New, options?: CreateApiKeyOptions) { + create(apiKey: New, options?: CreateApiKeyOptions) { return this.api.post(this.buildPath(ApiKey.baseUrl, options), apiKey); } diff --git a/src/resources/ApiKeys/ApiKeysInterfaces.ts b/src/resources/ApiKeys/ApiKeysInterfaces.ts index e936d0072..98b80367b 100644 --- a/src/resources/ApiKeys/ApiKeysInterfaces.ts +++ b/src/resources/ApiKeys/ApiKeysInterfaces.ts @@ -1,5 +1,5 @@ import {GranularResource, PrivilegeModel} from '../BaseInterfaces.js'; - +import { ApiKeyStatus } from '../Enums.js'; export interface ApiKeyModel extends GranularResource { /** * The unique identifier of the [organization](https://docs.coveo.com/en/222/) the API key was created for. @@ -10,7 +10,7 @@ export interface ApiKeyModel extends GranularResource { * * **Example:** t4hk287bfj5sg6wskg64ckk5a */ - id?: string; + id: string; /** * Whether the API key is enabled. */ @@ -84,6 +84,18 @@ export interface ApiKeyModel extends GranularResource { * Additional configuration to be included in an API key. [to be revised] */ additionalConfiguration?: AdditionalConfigurationModel; + /** + * The expiration date of the API key. + */ + expirationDate?: number; + /** + * The status of the API key. + */ + status?: ApiKeyStatus; + /** + * The ID of the template to which the API key is bound. + */ + apiKeyTemplateId?: string } export interface CreateApiKeyOptions { @@ -138,4 +150,4 @@ interface EnforceQueryPipelineConfigurationModel { interface ImpersonationRestrictionsModel { allowedUserIds: QueryAuthenticationModel[]; -} +} \ No newline at end of file diff --git a/src/resources/Enums.ts b/src/resources/Enums.ts index 0b40a7adc..57adf1b58 100644 --- a/src/resources/Enums.ts +++ b/src/resources/Enums.ts @@ -1168,3 +1168,12 @@ export enum ProductsSortByType { export enum FeedbackConsumerType { SOURCE_MANAGEMENT_IMPROVEMENTS = 'SOURCE_MANAGEMENT_IMPROVEMENTS', } + +export enum ApiKeyStatus { + ENABLED='EXPIRED', + DISABLED='DISABLED', + DISABLED_FOR_INACTIVITY='DISABLED_FOR_INACTIVITY', + EXPIRED='EXPIRED', + SOON_TO_BE_EXPIRED='SOON_TO_BE_EXPIRED', + SOON_TO_BE_DISABLED='SOON_TO_BE_DISABLED' +}