UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

326 lines 13.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ShieldListsManager = exports.UpdateShieldListByIdV2025R0Headers = exports.DeleteShieldListByIdV2025R0Headers = exports.GetShieldListByIdV2025R0Headers = exports.CreateShieldListV2025R0Headers = exports.GetShieldListsV2025R0Headers = exports.UpdateShieldListByIdV2025R0Optionals = exports.DeleteShieldListByIdV2025R0Optionals = exports.GetShieldListByIdV2025R0Optionals = exports.CreateShieldListV2025R0Optionals = void 0; const shieldListsV2025R0_1 = require("../schemas/v2025R0/shieldListsV2025R0"); const shieldListV2025R0_1 = require("../schemas/v2025R0/shieldListV2025R0"); const shieldListsCreateV2025R0_1 = require("../schemas/v2025R0/shieldListsCreateV2025R0"); const shieldListsUpdateV2025R0_1 = require("../schemas/v2025R0/shieldListsUpdateV2025R0"); const network_1 = require("../networking/network"); const fetchOptions_1 = require("../networking/fetchOptions"); const utils_1 = require("../internal/utils"); const utils_2 = require("../internal/utils"); class CreateShieldListV2025R0Optionals { headers = new CreateShieldListV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.CreateShieldListV2025R0Optionals = CreateShieldListV2025R0Optionals; class GetShieldListByIdV2025R0Optionals { headers = new GetShieldListByIdV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.GetShieldListByIdV2025R0Optionals = GetShieldListByIdV2025R0Optionals; class DeleteShieldListByIdV2025R0Optionals { headers = new DeleteShieldListByIdV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.DeleteShieldListByIdV2025R0Optionals = DeleteShieldListByIdV2025R0Optionals; class UpdateShieldListByIdV2025R0Optionals { headers = new UpdateShieldListByIdV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.UpdateShieldListByIdV2025R0Optionals = UpdateShieldListByIdV2025R0Optionals; class GetShieldListsV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } exports.GetShieldListsV2025R0Headers = GetShieldListsV2025R0Headers; class CreateShieldListV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } exports.CreateShieldListV2025R0Headers = CreateShieldListV2025R0Headers; class GetShieldListByIdV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } exports.GetShieldListByIdV2025R0Headers = GetShieldListByIdV2025R0Headers; class DeleteShieldListByIdV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } exports.DeleteShieldListByIdV2025R0Headers = DeleteShieldListByIdV2025R0Headers; class UpdateShieldListByIdV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } exports.UpdateShieldListByIdV2025R0Headers = UpdateShieldListByIdV2025R0Headers; class ShieldListsManager { auth; networkSession = new network_1.NetworkSession({}); constructor(fields) { if (fields.auth !== undefined) { this.auth = fields.auth; } if (fields.networkSession !== undefined) { this.networkSession = fields.networkSession; } } /** * Retrieves all shield lists in the enterprise. * @param {GetShieldListsV2025R0HeadersInput} headersInput Headers of getShieldListsV2025R0 method * @param {CancellationToken} cancellationToken Token used for request cancellation. * @returns {Promise<ShieldListsV2025R0>} */ async getShieldListsV2025R0(headersInput = new GetShieldListsV2025R0Headers({}), cancellationToken) { const headers = new GetShieldListsV2025R0Headers({ boxVersion: headersInput.boxVersion, extraHeaders: headersInput.extraHeaders, }); const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/shield_lists'), method: 'GET', headers: headersMap, responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, shieldListsV2025R0_1.deserializeShieldListsV2025R0)(response.data), rawData: response.data, }; } /** * Creates a shield list. * @param {ShieldListsCreateV2025R0} requestBody Request body of createShieldListV2025R0 method * @param {CreateShieldListV2025R0OptionalsInput} optionalsInput * @returns {Promise<ShieldListV2025R0>} */ async createShieldListV2025R0(requestBody, optionalsInput = {}) { const optionals = new CreateShieldListV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/shield_lists'), method: 'POST', headers: headersMap, data: (0, shieldListsCreateV2025R0_1.serializeShieldListsCreateV2025R0)(requestBody), contentType: 'application/json', responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, shieldListV2025R0_1.deserializeShieldListV2025R0)(response.data), rawData: response.data, }; } /** * Retrieves a single shield list by its ID. * @param {string} shieldListId The unique identifier that represents a shield list. The ID for any Shield List can be determined by the response from the endpoint fetching all shield lists for the enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 " * @param {GetShieldListByIdV2025R0OptionalsInput} optionalsInput * @returns {Promise<ShieldListV2025R0>} */ async getShieldListByIdV2025R0(shieldListId, optionalsInput = {}) { const optionals = new GetShieldListByIdV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/shield_lists/', (0, utils_2.toString)(shieldListId)), method: 'GET', headers: headersMap, responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, shieldListV2025R0_1.deserializeShieldListV2025R0)(response.data), rawData: response.data, }; } /** * Delete a single shield list by its ID. * @param {string} shieldListId The unique identifier that represents a shield list. The ID for any Shield List can be determined by the response from the endpoint fetching all shield lists for the enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 " * @param {DeleteShieldListByIdV2025R0OptionalsInput} optionalsInput * @returns {Promise<undefined>} */ async deleteShieldListByIdV2025R0(shieldListId, optionalsInput = {}) { const optionals = new DeleteShieldListByIdV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/shield_lists/', (0, utils_2.toString)(shieldListId)), method: 'DELETE', headers: headersMap, responseFormat: 'no_content', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return void 0; } /** * Updates a shield list. * @param {string} shieldListId The unique identifier that represents a shield list. The ID for any Shield List can be determined by the response from the endpoint fetching all shield lists for the enterprise. Example: "90fb0e17-c332-40ed-b4f9-fa8908fbbb24 " * @param {ShieldListsUpdateV2025R0} requestBody Request body of updateShieldListByIdV2025R0 method * @param {UpdateShieldListByIdV2025R0OptionalsInput} optionalsInput * @returns {Promise<ShieldListV2025R0>} */ async updateShieldListByIdV2025R0(shieldListId, requestBody, optionalsInput = {}) { const optionals = new UpdateShieldListByIdV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/shield_lists/', (0, utils_2.toString)(shieldListId)), method: 'PUT', headers: headersMap, data: (0, shieldListsUpdateV2025R0_1.serializeShieldListsUpdateV2025R0)(requestBody), contentType: 'application/json', responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, shieldListV2025R0_1.deserializeShieldListV2025R0)(response.data), rawData: response.data, }; } } exports.ShieldListsManager = ShieldListsManager; //# sourceMappingURL=shieldLists.js.map