|
| 1 | +import { serializeShieldListV2025R0 } from '../schemas/v2025R0/shieldListV2025R0.generated.js'; |
| 2 | +import { deserializeShieldListV2025R0 } from '../schemas/v2025R0/shieldListV2025R0.generated.js'; |
| 3 | +import { serializeShieldListsCreateV2025R0 } from '../schemas/v2025R0/shieldListsCreateV2025R0.generated.js'; |
| 4 | +import { deserializeShieldListsCreateV2025R0 } from '../schemas/v2025R0/shieldListsCreateV2025R0.generated.js'; |
| 5 | +import { serializeShieldListContentCountryV2025R0TypeField } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js'; |
| 6 | +import { deserializeShieldListContentCountryV2025R0TypeField } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js'; |
| 7 | +import { serializeShieldListContentDomainV2025R0TypeField } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js'; |
| 8 | +import { deserializeShieldListContentDomainV2025R0TypeField } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js'; |
| 9 | +import { serializeShieldListContentEmailV2025R0TypeField } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js'; |
| 10 | +import { deserializeShieldListContentEmailV2025R0TypeField } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js'; |
| 11 | +import { serializeShieldListContentIpV2025R0TypeField } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js'; |
| 12 | +import { deserializeShieldListContentIpV2025R0TypeField } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js'; |
| 13 | +import { serializeShieldListsV2025R0 } from '../schemas/v2025R0/shieldListsV2025R0.generated.js'; |
| 14 | +import { deserializeShieldListsV2025R0 } from '../schemas/v2025R0/shieldListsV2025R0.generated.js'; |
| 15 | +import { serializeShieldListsUpdateV2025R0 } from '../schemas/v2025R0/shieldListsUpdateV2025R0.generated.js'; |
| 16 | +import { deserializeShieldListsUpdateV2025R0 } from '../schemas/v2025R0/shieldListsUpdateV2025R0.generated.js'; |
| 17 | +import { serializeShieldListContentCountryV2025R0 } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js'; |
| 18 | +import { deserializeShieldListContentCountryV2025R0 } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js'; |
| 19 | +import { serializeShieldListContentDomainV2025R0 } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js'; |
| 20 | +import { deserializeShieldListContentDomainV2025R0 } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js'; |
| 21 | +import { serializeShieldListContentEmailV2025R0 } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js'; |
| 22 | +import { deserializeShieldListContentEmailV2025R0 } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js'; |
| 23 | +import { serializeShieldListContentIpV2025R0 } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js'; |
| 24 | +import { deserializeShieldListContentIpV2025R0 } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js'; |
| 25 | +import { BoxClient } from '../client.generated.js'; |
| 26 | +import { ShieldListV2025R0 } from '../schemas/v2025R0/shieldListV2025R0.generated.js'; |
| 27 | +import { ShieldListsCreateV2025R0 } from '../schemas/v2025R0/shieldListsCreateV2025R0.generated.js'; |
| 28 | +import { ShieldListContentCountryV2025R0TypeField } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js'; |
| 29 | +import { ShieldListContentDomainV2025R0TypeField } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js'; |
| 30 | +import { ShieldListContentEmailV2025R0TypeField } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js'; |
| 31 | +import { ShieldListContentIpV2025R0TypeField } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js'; |
| 32 | +import { ShieldListsV2025R0 } from '../schemas/v2025R0/shieldListsV2025R0.generated.js'; |
| 33 | +import { ShieldListsUpdateV2025R0 } from '../schemas/v2025R0/shieldListsUpdateV2025R0.generated.js'; |
| 34 | +import { getUuid } from '../internal/utils.js'; |
| 35 | +import { getEnvVar } from '../internal/utils.js'; |
| 36 | +import { uploadNewFile } from './commons.generated.js'; |
| 37 | +import { createNewFolder } from './commons.generated.js'; |
| 38 | +import { getDefaultClientWithUserSubject } from './commons.generated.js'; |
| 39 | +import { ShieldListContentCountryV2025R0 } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js'; |
| 40 | +import { ShieldListContentDomainV2025R0 } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js'; |
| 41 | +import { ShieldListContentEmailV2025R0 } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js'; |
| 42 | +import { ShieldListContentIpV2025R0 } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js'; |
| 43 | +import { SerializedData } from '../serialization/json.js'; |
| 44 | +import { sdIsEmpty } from '../serialization/json.js'; |
| 45 | +import { sdIsBoolean } from '../serialization/json.js'; |
| 46 | +import { sdIsNumber } from '../serialization/json.js'; |
| 47 | +import { sdIsString } from '../serialization/json.js'; |
| 48 | +import { sdIsList } from '../serialization/json.js'; |
| 49 | +import { sdIsMap } from '../serialization/json.js'; |
| 50 | +export const userId: string = getEnvVar('USER_ID'); |
| 51 | +export const client: BoxClient = getDefaultClientWithUserSubject(userId); |
| 52 | +test('testCreateGetUpdateDeleteShieldList', async function testCreateGetUpdateDeleteShieldList(): Promise<any> { |
| 53 | + const shieldListCountryName: string = ''.concat( |
| 54 | + getUuid(), |
| 55 | + 'shieldListCountry', |
| 56 | + ) as string; |
| 57 | + const shieldListCountry: ShieldListV2025R0 = |
| 58 | + await client.shieldLists.createShieldListV2025R0({ |
| 59 | + name: shieldListCountryName, |
| 60 | + description: 'A list of things that are shielded', |
| 61 | + content: new ShieldListContentCountryV2025R0({ |
| 62 | + type: 'country' as ShieldListContentCountryV2025R0TypeField, |
| 63 | + countryCodes: ['US' as string, 'PL' as string], |
| 64 | + }), |
| 65 | + } satisfies ShieldListsCreateV2025R0); |
| 66 | + const shieldListContentDomainName: string = ''.concat( |
| 67 | + getUuid(), |
| 68 | + 'shieldListContentDomain', |
| 69 | + ) as string; |
| 70 | + const shieldListContentDomain: ShieldListV2025R0 = |
| 71 | + await client.shieldLists.createShieldListV2025R0({ |
| 72 | + name: shieldListContentDomainName, |
| 73 | + description: 'A list of things that are shielded', |
| 74 | + content: new ShieldListContentDomainV2025R0({ |
| 75 | + type: 'domain' as ShieldListContentDomainV2025R0TypeField, |
| 76 | + domains: ['box.com' as string, 'example.com' as string], |
| 77 | + }), |
| 78 | + } satisfies ShieldListsCreateV2025R0); |
| 79 | + const shieldListContentEmailName: string = ''.concat( |
| 80 | + getUuid(), |
| 81 | + 'shieldListContentEmail', |
| 82 | + ) as string; |
| 83 | + const shieldListContentEmail: ShieldListV2025R0 = |
| 84 | + await client.shieldLists.createShieldListV2025R0({ |
| 85 | + name: shieldListContentEmailName, |
| 86 | + description: 'A list of things that are shielded', |
| 87 | + content: new ShieldListContentEmailV2025R0({ |
| 88 | + type: 'email' as ShieldListContentEmailV2025R0TypeField, |
| 89 | + emailAddresses: [ |
| 90 | + |
| 91 | + |
| 92 | + ], |
| 93 | + }), |
| 94 | + } satisfies ShieldListsCreateV2025R0); |
| 95 | + const shieldListContentIpName: string = ''.concat( |
| 96 | + getUuid(), |
| 97 | + 'shieldListContentIp', |
| 98 | + ) as string; |
| 99 | + const shieldListContentIp: ShieldListV2025R0 = |
| 100 | + await client.shieldLists.createShieldListV2025R0({ |
| 101 | + name: shieldListContentIpName, |
| 102 | + description: 'A list of things that are shielded', |
| 103 | + content: new ShieldListContentIpV2025R0({ |
| 104 | + type: 'ip' as ShieldListContentIpV2025R0TypeField, |
| 105 | + ipAddresses: ['127.0.0.1' as string, '80.12.12.12/24' as string], |
| 106 | + }), |
| 107 | + } satisfies ShieldListsCreateV2025R0); |
| 108 | + const shieldLists: ShieldListsV2025R0 = |
| 109 | + await client.shieldLists.getShieldListsV2025R0(); |
| 110 | + if (!(shieldLists.entries!.length > 0)) { |
| 111 | + throw new Error('Assertion failed'); |
| 112 | + } |
| 113 | + const getShieldListCountry: ShieldListV2025R0 = |
| 114 | + await client.shieldLists.getShieldListByIdV2025R0(shieldListCountry.id); |
| 115 | + if (!(getShieldListCountry.name == shieldListCountryName)) { |
| 116 | + throw new Error('Assertion failed'); |
| 117 | + } |
| 118 | + if ( |
| 119 | + !(getShieldListCountry.description == 'A list of things that are shielded') |
| 120 | + ) { |
| 121 | + throw new Error('Assertion failed'); |
| 122 | + } |
| 123 | + await client.shieldLists.updateShieldListByIdV2025R0(shieldListCountry.id, { |
| 124 | + name: shieldListCountryName, |
| 125 | + description: 'Updated description', |
| 126 | + content: new ShieldListContentCountryV2025R0({ |
| 127 | + type: 'country' as ShieldListContentCountryV2025R0TypeField, |
| 128 | + countryCodes: ['US' as string], |
| 129 | + }), |
| 130 | + } satisfies ShieldListsUpdateV2025R0); |
| 131 | + const getShieldListCountryUpdated: ShieldListV2025R0 = |
| 132 | + await client.shieldLists.getShieldListByIdV2025R0(shieldListCountry.id); |
| 133 | + if (!(getShieldListCountryUpdated.description == 'Updated description')) { |
| 134 | + throw new Error('Assertion failed'); |
| 135 | + } |
| 136 | + await client.shieldLists.deleteShieldListByIdV2025R0(shieldListCountry.id); |
| 137 | + await client.shieldLists.deleteShieldListByIdV2025R0( |
| 138 | + shieldListContentDomain.id, |
| 139 | + ); |
| 140 | + await client.shieldLists.deleteShieldListByIdV2025R0( |
| 141 | + shieldListContentEmail.id, |
| 142 | + ); |
| 143 | + await client.shieldLists.deleteShieldListByIdV2025R0(shieldListContentIp.id); |
| 144 | +}); |
| 145 | +export {}; |
0 commit comments