Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "7c94f4f", "specHash": "a646ae6", "version": "4.0.0" }
{ "engineHash": "7c94f4f", "specHash": "8b51a89", "version": "4.0.0" }
29 changes: 29 additions & 0 deletions docs/sdk-gen/archives.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [List archives](#list-archives)
- [Create archive](#create-archive)
- [Delete archive](#delete-archive)
- [Update archive](#update-archive)

## List archives

Expand Down Expand Up @@ -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.


204 changes: 202 additions & 2 deletions src/sdk-gen/managers/archives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<UpdateArchiveByIdV2025R0Headers, 'boxVersion' | 'extraHeaders'>
>
) {
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({});
Expand All @@ -210,6 +298,7 @@ export class ArchivesManager {
| 'getArchivesV2025R0'
| 'createArchiveV2025R0'
| 'deleteArchiveByIdV2025R0'
| 'updateArchiveByIdV2025R0'
> &
Partial<Pick<ArchivesManager, 'networkSession'>>
) {
Expand Down Expand Up @@ -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<ArchiveV2025R0>}
*/
async updateArchiveByIdV2025R0(
archiveId: string,
optionalsInput: UpdateArchiveByIdV2025R0OptionalsInput = {}
): Promise<ArchiveV2025R0> {
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;
Expand All @@ -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
Expand All @@ -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;
}
Loading
Loading