diff --git a/.codegen.json b/.codegen.json index 77d644c09..76d169ba9 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "7c94f4f", "specHash": "a646ae6", "version": "4.0.0" } +{ "engineHash": "7c94f4f", "specHash": "8b51a89", "version": "4.0.0" } diff --git a/docs/sdk-gen/archives.md b/docs/sdk-gen/archives.md index 1049cee72..ad3e63633 100644 --- a/docs/sdk-gen/archives.md +++ b/docs/sdk-gen/archives.md @@ -4,6 +4,7 @@ - [List archives](#list-archives) - [Create archive](#create-archive) - [Delete archive](#delete-archive) +- [Update archive](#update-archive) ## List archives @@ -100,3 +101,31 @@ This function returns a value of type `undefined`. Returns an empty response when the archive has been deleted. +## Update archive + +Updates an archive. + +To learn more about the archive APIs, see the [Archive API Guide](g://archives). + +This operation is performed by calling function `updateArchiveByIdV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/put-archives-id/). + +*Currently we don't have an example for calling `updateArchiveByIdV2025R0` in integration tests* + +### Arguments + +- archiveId `string` + - The ID of the archive. Example: "982312" +- optionalsInput `UpdateArchiveByIdV2025R0OptionalsInput` + + + +### Returns + +This function returns a value of type `ArchiveV2025R0`. + +Returns the updated archive object. + + diff --git a/src/sdk-gen/managers/archives.ts b/src/sdk-gen/managers/archives.ts index a29c38796..4097a94f0 100644 --- a/src/sdk-gen/managers/archives.ts +++ b/src/sdk-gen/managers/archives.ts @@ -78,6 +78,40 @@ export interface DeleteArchiveByIdV2025R0OptionalsInput { readonly headers?: DeleteArchiveByIdV2025R0Headers; readonly cancellationToken?: undefined | CancellationToken; } +export class UpdateArchiveByIdV2025R0Optionals { + readonly requestBody: UpdateArchiveByIdV2025R0RequestBody = + {} satisfies UpdateArchiveByIdV2025R0RequestBody; + readonly headers: UpdateArchiveByIdV2025R0Headers = + new UpdateArchiveByIdV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + UpdateArchiveByIdV2025R0Optionals, + 'requestBody' | 'headers' | 'cancellationToken' + > & + Partial< + Pick< + UpdateArchiveByIdV2025R0Optionals, + 'requestBody' | 'headers' | 'cancellationToken' + > + > + ) { + if (fields.requestBody !== undefined) { + this.requestBody = fields.requestBody; + } + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface UpdateArchiveByIdV2025R0OptionalsInput { + readonly requestBody?: UpdateArchiveByIdV2025R0RequestBody; + readonly headers?: UpdateArchiveByIdV2025R0Headers; + readonly cancellationToken?: undefined | CancellationToken; +} export interface GetArchivesV2025R0QueryParams { /** * The maximum number of items to return per page. */ @@ -125,6 +159,12 @@ export interface CreateArchiveV2025R0RequestBody { /** * The name of the archive. */ readonly name: string; + /** + * The description of the archive. */ + readonly description?: string; + /** + * The ID of the storage policy that the archive is assigned to. */ + readonly storagePolicyId?: string; readonly rawData?: SerializedData; } export class CreateArchiveV2025R0Headers { @@ -200,6 +240,54 @@ export interface DeleteArchiveByIdV2025R0HeadersInput { readonly [key: string]: undefined | string; }; } +export interface UpdateArchiveByIdV2025R0RequestBody { + /** + * The name of the archive. */ + readonly name?: string; + /** + * The description of the archive. */ + readonly description?: string; + readonly rawData?: SerializedData; +} +export class UpdateArchiveByIdV2025R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2025R0 = + '2025.0' as BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit< + UpdateArchiveByIdV2025R0Headers, + 'boxVersion' | 'extraHeaders' + > & + Partial< + Pick + > + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface UpdateArchiveByIdV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} export class ArchivesManager { readonly auth?: Authentication; readonly networkSession: NetworkSession = new NetworkSession({}); @@ -210,6 +298,7 @@ export class ArchivesManager { | 'getArchivesV2025R0' | 'createArchiveV2025R0' | 'deleteArchiveByIdV2025R0' + | 'updateArchiveByIdV2025R0' > & Partial> ) { @@ -364,6 +453,57 @@ export class ArchivesManager { ); return void 0; } + /** + * Updates an archive. + * + * To learn more about the archive APIs, see the [Archive API Guide](g://archives). + * @param {string} archiveId The ID of the archive. + Example: "982312" + * @param {UpdateArchiveByIdV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async updateArchiveByIdV2025R0( + archiveId: string, + optionalsInput: UpdateArchiveByIdV2025R0OptionalsInput = {} + ): Promise { + const optionals: UpdateArchiveByIdV2025R0Optionals = + new UpdateArchiveByIdV2025R0Optionals({ + requestBody: optionalsInput.requestBody, + headers: optionalsInput.headers, + cancellationToken: optionalsInput.cancellationToken, + }); + const requestBody: any = optionals.requestBody; + const headers: any = optionals.headers; + const cancellationToken: any = optionals.cancellationToken; + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['box-version']: toString(headers.boxVersion) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/archives/', + toString(archiveId) as string + ) as string, + method: 'PUT', + headers: headersMap, + data: serializeUpdateArchiveByIdV2025R0RequestBody(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }) + ); + return { + ...deserializeArchiveV2025R0(response.data!), + rawData: response.data!, + }; + } } export interface ArchivesManagerInput { readonly auth?: Authentication; @@ -372,7 +512,11 @@ export interface ArchivesManagerInput { export function serializeCreateArchiveV2025R0RequestBody( val: CreateArchiveV2025R0RequestBody ): SerializedData { - return { ['name']: val.name }; + return { + ['name']: val.name, + ['description']: val.description, + ['storage_policy_id']: val.storagePolicyId, + }; } export function deserializeCreateArchiveV2025R0RequestBody( val: SerializedData @@ -395,5 +539,61 @@ export function deserializeCreateArchiveV2025R0RequestBody( }); } const name: string = val.name; - return { name: name } satisfies CreateArchiveV2025R0RequestBody; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: + 'Expecting string for "description" of type "CreateArchiveV2025R0RequestBody"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + if ( + !(val.storage_policy_id == void 0) && + !sdIsString(val.storage_policy_id) + ) { + throw new BoxSdkError({ + message: + 'Expecting string for "storage_policy_id" of type "CreateArchiveV2025R0RequestBody"', + }); + } + const storagePolicyId: undefined | string = + val.storage_policy_id == void 0 ? void 0 : val.storage_policy_id; + return { + name: name, + description: description, + storagePolicyId: storagePolicyId, + } satisfies CreateArchiveV2025R0RequestBody; +} +export function serializeUpdateArchiveByIdV2025R0RequestBody( + val: UpdateArchiveByIdV2025R0RequestBody +): SerializedData { + return { ['name']: val.name, ['description']: val.description }; +} +export function deserializeUpdateArchiveByIdV2025R0RequestBody( + val: SerializedData +): UpdateArchiveByIdV2025R0RequestBody { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "UpdateArchiveByIdV2025R0RequestBody"', + }); + } + if (!(val.name == void 0) && !sdIsString(val.name)) { + throw new BoxSdkError({ + message: + 'Expecting string for "name" of type "UpdateArchiveByIdV2025R0RequestBody"', + }); + } + const name: undefined | string = val.name == void 0 ? void 0 : val.name; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: + 'Expecting string for "description" of type "UpdateArchiveByIdV2025R0RequestBody"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + return { + name: name, + description: description, + } satisfies UpdateArchiveByIdV2025R0RequestBody; } diff --git a/src/sdk-gen/schemas/v2025R0/archiveV2025R0.ts b/src/sdk-gen/schemas/v2025R0/archiveV2025R0.ts index be94ae7a7..34d99bf8b 100644 --- a/src/sdk-gen/schemas/v2025R0/archiveV2025R0.ts +++ b/src/sdk-gen/schemas/v2025R0/archiveV2025R0.ts @@ -7,12 +7,21 @@ import { sdIsString } from '../../serialization/json'; import { sdIsList } from '../../serialization/json'; import { sdIsMap } from '../../serialization/json'; export type ArchiveV2025R0TypeField = 'archive'; +export interface ArchiveV2025R0OwnedByField { + /** + * The unique identifier that represents a user who owns the archive. */ + readonly id: string; + /** + * The value is always `user`. */ + readonly type: string; + readonly rawData?: SerializedData; +} export class ArchiveV2025R0 { /** * The unique identifier that represents an archive. */ readonly id!: string; /** - * The value will always be `archive`. */ + * The value is always `archive`. */ readonly type: ArchiveV2025R0TypeField = 'archive' as ArchiveV2025R0TypeField; /** * The name of the archive. @@ -25,6 +34,12 @@ export class ArchiveV2025R0 { /** * The size of the archive in bytes. */ readonly size!: number; + /** + * The description of the archive. */ + readonly description?: string | null; + /** + * The part of an archive API response that describes the user who owns the archive. */ + readonly ownedBy?: ArchiveV2025R0OwnedByField; readonly rawData?: SerializedData; constructor( fields: Omit & Partial> @@ -41,6 +56,12 @@ export class ArchiveV2025R0 { if (fields.size !== undefined) { this.size = fields.size; } + if (fields.description !== undefined) { + this.description = fields.description; + } + if (fields.ownedBy !== undefined) { + this.ownedBy = fields.ownedBy; + } if (fields.rawData !== undefined) { this.rawData = fields.rawData; } @@ -51,7 +72,7 @@ export interface ArchiveV2025R0Input { * The unique identifier that represents an archive. */ readonly id: string; /** - * The value will always be `archive`. */ + * The value is always `archive`. */ readonly type?: ArchiveV2025R0TypeField; /** * The name of the archive. @@ -64,6 +85,12 @@ export interface ArchiveV2025R0Input { /** * The size of the archive in bytes. */ readonly size: number; + /** + * The description of the archive. */ + readonly description?: string | null; + /** + * The part of an archive API response that describes the user who owns the archive. */ + readonly ownedBy?: ArchiveV2025R0OwnedByField; readonly rawData?: SerializedData; } export function serializeArchiveV2025R0TypeField( @@ -81,12 +108,57 @@ export function deserializeArchiveV2025R0TypeField( message: "Can't deserialize ArchiveV2025R0TypeField", }); } +export function serializeArchiveV2025R0OwnedByField( + val: ArchiveV2025R0OwnedByField +): SerializedData { + return { ['id']: val.id, ['type']: val.type }; +} +export function deserializeArchiveV2025R0OwnedByField( + val: SerializedData +): ArchiveV2025R0OwnedByField { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "ArchiveV2025R0OwnedByField"', + }); + } + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "ArchiveV2025R0OwnedByField" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "ArchiveV2025R0OwnedByField"', + }); + } + const id: string = val.id; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "ArchiveV2025R0OwnedByField" to be defined', + }); + } + if (!sdIsString(val.type)) { + throw new BoxSdkError({ + message: + 'Expecting string for "type" of type "ArchiveV2025R0OwnedByField"', + }); + } + const type: string = val.type; + return { id: id, type: type } satisfies ArchiveV2025R0OwnedByField; +} export function serializeArchiveV2025R0(val: ArchiveV2025R0): SerializedData { return { ['id']: val.id, ['type']: serializeArchiveV2025R0TypeField(val.type), ['name']: val.name, ['size']: val.size, + ['description']: val.description, + ['owned_by']: + val.ownedBy == void 0 + ? val.ownedBy + : serializeArchiveV2025R0OwnedByField(val.ownedBy), }; } export function deserializeArchiveV2025R0(val: SerializedData): ArchiveV2025R0 { @@ -134,11 +206,24 @@ export function deserializeArchiveV2025R0(val: SerializedData): ArchiveV2025R0 { }); } const size: number = val.size; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: 'Expecting string for "description" of type "ArchiveV2025R0"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + const ownedBy: undefined | ArchiveV2025R0OwnedByField = + val.owned_by == void 0 + ? void 0 + : deserializeArchiveV2025R0OwnedByField(val.owned_by); return { id: id, type: type, name: name, size: size, + description: description, + ownedBy: ownedBy, } satisfies ArchiveV2025R0; } export function serializeArchiveV2025R0Input( @@ -152,6 +237,11 @@ export function serializeArchiveV2025R0Input( : serializeArchiveV2025R0TypeField(val.type), ['name']: val.name, ['size']: val.size, + ['description']: val.description, + ['owned_by']: + val.ownedBy == void 0 + ? val.ownedBy + : serializeArchiveV2025R0OwnedByField(val.ownedBy), }; } export function deserializeArchiveV2025R0Input( @@ -197,10 +287,24 @@ export function deserializeArchiveV2025R0Input( }); } const size: number = val.size; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: + 'Expecting string for "description" of type "ArchiveV2025R0Input"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + const ownedBy: undefined | ArchiveV2025R0OwnedByField = + val.owned_by == void 0 + ? void 0 + : deserializeArchiveV2025R0OwnedByField(val.owned_by); return { id: id, type: type, name: name, size: size, + description: description, + ownedBy: ownedBy, } satisfies ArchiveV2025R0Input; } diff --git a/src/sdk-gen/schemas/v2025R0/hubItemReferenceV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubItemReferenceV2025R0.ts index c2d6f726d..4e6582155 100644 --- a/src/sdk-gen/schemas/v2025R0/hubItemReferenceV2025R0.ts +++ b/src/sdk-gen/schemas/v2025R0/hubItemReferenceV2025R0.ts @@ -26,7 +26,7 @@ export function serializeHubItemReferenceV2025R0(val: any): SerializedData { if (val.type == 'folder') { return serializeFolderReferenceV2025R0(val); } - if (val.type == 'weblink') { + if (val.type == 'web_link') { return serializeWeblinkReferenceV2025R0(val); } throw new BoxSdkError({ message: 'unknown type' }); @@ -45,7 +45,7 @@ export function deserializeHubItemReferenceV2025R0( if (val.type == 'folder') { return deserializeFolderReferenceV2025R0(val); } - if (val.type == 'weblink') { + if (val.type == 'web_link') { return deserializeWeblinkReferenceV2025R0(val); } throw new BoxSdkError({ diff --git a/src/sdk-gen/schemas/v2025R0/weblinkReferenceV2025R0.ts b/src/sdk-gen/schemas/v2025R0/weblinkReferenceV2025R0.ts index 52a845098..69975664a 100644 --- a/src/sdk-gen/schemas/v2025R0/weblinkReferenceV2025R0.ts +++ b/src/sdk-gen/schemas/v2025R0/weblinkReferenceV2025R0.ts @@ -6,12 +6,12 @@ import { sdIsNumber } from '../../serialization/json'; import { sdIsString } from '../../serialization/json'; import { sdIsList } from '../../serialization/json'; import { sdIsMap } from '../../serialization/json'; -export type WeblinkReferenceV2025R0TypeField = 'weblink'; +export type WeblinkReferenceV2025R0TypeField = 'web_link'; export class WeblinkReferenceV2025R0 { /** - * The value will always be `weblink`. */ + * The value will always be `web_link`. */ readonly type: WeblinkReferenceV2025R0TypeField = - 'weblink' as WeblinkReferenceV2025R0TypeField; + 'web_link' as WeblinkReferenceV2025R0TypeField; /** * ID of the web link. */ readonly id!: string; @@ -33,7 +33,7 @@ export class WeblinkReferenceV2025R0 { } export interface WeblinkReferenceV2025R0Input { /** - * The value will always be `weblink`. */ + * The value will always be `web_link`. */ readonly type?: WeblinkReferenceV2025R0TypeField; /** * ID of the web link. */ @@ -48,7 +48,7 @@ export function serializeWeblinkReferenceV2025R0TypeField( export function deserializeWeblinkReferenceV2025R0TypeField( val: SerializedData ): WeblinkReferenceV2025R0TypeField { - if (val == 'weblink') { + if (val == 'web_link') { return val; } throw new BoxSdkError({