@api-client/core 0.12.12 → 0.12.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/browser.d.ts +3 -3
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +2 -2
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +3 -3
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -2
- package/build/src/index.js.map +1 -1
- package/build/src/mocking/lib/User.d.ts +2 -0
- package/build/src/mocking/lib/User.d.ts.map +1 -1
- package/build/src/mocking/lib/User.js +6 -0
- package/build/src/mocking/lib/User.js.map +1 -1
- package/build/src/models/store/User.d.ts +23 -2
- package/build/src/models/store/User.d.ts.map +1 -1
- package/build/src/models/store/User.js.map +1 -1
- package/build/src/proxy/HttpProjectProxy.js +1 -1
- package/build/src/proxy/HttpProjectProxy.js.map +1 -1
- package/build/src/sdk/AuthSdk.d.ts.map +1 -0
- package/build/src/sdk/AuthSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/DataCatalogSdk.d.ts +5 -5
- package/build/src/sdk/DataCatalogSdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/DataCatalogSdk.js +2 -2
- package/build/src/sdk/DataCatalogSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/FilesSdk.d.ts +7 -7
- package/build/src/sdk/FilesSdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/FilesSdk.js +2 -2
- package/build/src/sdk/FilesSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/HistorySdk.d.ts +2 -2
- package/build/src/sdk/HistorySdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/HistorySdk.js +2 -2
- package/build/src/sdk/HistorySdk.js.map +1 -0
- package/build/src/sdk/Http.d.ts.map +1 -0
- package/build/src/sdk/Http.js.map +1 -0
- package/build/src/sdk/HttpNode.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/HttpNode.js +1 -2
- package/build/src/sdk/HttpNode.js.map +1 -0
- package/build/src/{runtime/store → sdk}/HttpWeb.d.ts +1 -1
- package/build/src/sdk/HttpWeb.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/HttpWeb.js +1 -1
- package/build/src/sdk/HttpWeb.js.map +1 -0
- package/build/src/sdk/OrganizationsSdk.d.ts +125 -0
- package/build/src/sdk/OrganizationsSdk.d.ts.map +1 -0
- package/build/src/sdk/OrganizationsSdk.js +457 -0
- package/build/src/sdk/OrganizationsSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/ProjectExecutionsSdk.d.ts +2 -2
- package/build/src/sdk/ProjectExecutionsSdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/ProjectExecutionsSdk.js +1 -1
- package/build/src/sdk/ProjectExecutionsSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/RevisionsSdk.d.ts +2 -2
- package/build/src/sdk/RevisionsSdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/RevisionsSdk.js +1 -1
- package/build/src/sdk/RevisionsSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/RouteBuilder.d.ts +3 -0
- package/build/src/sdk/RouteBuilder.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/RouteBuilder.js +9 -0
- package/build/src/sdk/RouteBuilder.js.map +1 -0
- package/build/src/{runtime/store → sdk}/Sdk.d.ts +1 -1
- package/build/src/sdk/Sdk.d.ts.map +1 -0
- package/build/src/sdk/Sdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/SdkBase.d.ts +3 -3
- package/build/src/sdk/SdkBase.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/SdkBase.js +1 -1
- package/build/src/sdk/SdkBase.js.map +1 -0
- package/build/src/{runtime/store → sdk}/SharedSdk.d.ts +2 -2
- package/build/src/sdk/SharedSdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/SharedSdk.js +1 -1
- package/build/src/sdk/SharedSdk.js.map +1 -0
- package/build/src/sdk/StoreSdkNode.d.ts.map +1 -0
- package/build/src/sdk/StoreSdkNode.js.map +1 -0
- package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -0
- package/build/src/sdk/StoreSdkWeb.js.map +1 -0
- package/build/src/{runtime/store → sdk}/TrashSdk.d.ts +2 -2
- package/build/src/sdk/TrashSdk.d.ts.map +1 -0
- package/build/src/{runtime/store → sdk}/TrashSdk.js +1 -1
- package/build/src/sdk/TrashSdk.js.map +1 -0
- package/build/src/{runtime/store → sdk}/UsersSdk.d.ts +1 -21
- package/build/src/sdk/UsersSdk.d.ts.map +1 -0
- package/build/src/sdk/UsersSdk.js +35 -0
- package/build/src/sdk/UsersSdk.js.map +1 -0
- package/build/src/sdk/WsClient.d.ts.map +1 -0
- package/build/src/sdk/WsClient.js.map +1 -0
- package/build/src/sdk/WsClientNode.d.ts.map +1 -0
- package/build/src/sdk/WsClientNode.js.map +1 -0
- package/build/src/sdk/WsClientWeb.d.ts.map +1 -0
- package/build/src/sdk/WsClientWeb.js.map +1 -0
- package/data/models/example-generator-api.json +14 -14
- package/package.json +3 -1
- package/src/mocking/lib/User.ts +6 -0
- package/src/models/store/User.ts +23 -2
- package/src/proxy/HttpProjectProxy.ts +1 -1
- package/src/{runtime/store → sdk}/DataCatalogSdk.ts +7 -7
- package/src/{runtime/store → sdk}/FilesSdk.ts +8 -8
- package/src/{runtime/store → sdk}/HistorySdk.ts +3 -3
- package/src/{runtime/store → sdk}/HttpNode.ts +1 -2
- package/src/{runtime/store → sdk}/HttpWeb.ts +2 -2
- package/src/sdk/OrganizationsSdk.ts +479 -0
- package/src/{runtime/store → sdk}/ProjectExecutionsSdk.ts +2 -2
- package/src/{runtime/store → sdk}/RevisionsSdk.ts +3 -3
- package/src/{runtime/store → sdk}/RouteBuilder.ts +12 -0
- package/src/{runtime/store → sdk}/Sdk.ts +1 -1
- package/src/{runtime/store → sdk}/SdkBase.ts +3 -3
- package/src/{runtime/store → sdk}/SharedSdk.ts +3 -3
- package/src/{runtime/store → sdk}/TrashSdk.ts +3 -3
- package/src/sdk/UsersSdk.ts +112 -0
- package/tests/unit/mocking/current/User.spec.ts +1 -1
- package/tests/unit/models/File/setDeleted.spec.ts +6 -0
- package/tests/unit/models/File/setLastModified.spec.ts +6 -0
- package/build/src/runtime/store/AuthSdk.d.ts.map +0 -1
- package/build/src/runtime/store/AuthSdk.js.map +0 -1
- package/build/src/runtime/store/DataCatalogSdk.d.ts.map +0 -1
- package/build/src/runtime/store/DataCatalogSdk.js.map +0 -1
- package/build/src/runtime/store/FilesSdk.d.ts.map +0 -1
- package/build/src/runtime/store/FilesSdk.js.map +0 -1
- package/build/src/runtime/store/HistorySdk.d.ts.map +0 -1
- package/build/src/runtime/store/HistorySdk.js.map +0 -1
- package/build/src/runtime/store/Http.d.ts.map +0 -1
- package/build/src/runtime/store/Http.js.map +0 -1
- package/build/src/runtime/store/HttpNode.d.ts.map +0 -1
- package/build/src/runtime/store/HttpNode.js.map +0 -1
- package/build/src/runtime/store/HttpWeb.d.ts.map +0 -1
- package/build/src/runtime/store/HttpWeb.js.map +0 -1
- package/build/src/runtime/store/OrganizationsSdk.d.ts +0 -86
- package/build/src/runtime/store/OrganizationsSdk.d.ts.map +0 -1
- package/build/src/runtime/store/OrganizationsSdk.js +0 -343
- package/build/src/runtime/store/OrganizationsSdk.js.map +0 -1
- package/build/src/runtime/store/ProjectExecutionsSdk.d.ts.map +0 -1
- package/build/src/runtime/store/ProjectExecutionsSdk.js.map +0 -1
- package/build/src/runtime/store/RevisionsSdk.d.ts.map +0 -1
- package/build/src/runtime/store/RevisionsSdk.js.map +0 -1
- package/build/src/runtime/store/RouteBuilder.d.ts.map +0 -1
- package/build/src/runtime/store/RouteBuilder.js.map +0 -1
- package/build/src/runtime/store/Sdk.d.ts.map +0 -1
- package/build/src/runtime/store/Sdk.js.map +0 -1
- package/build/src/runtime/store/SdkBase.d.ts.map +0 -1
- package/build/src/runtime/store/SdkBase.js.map +0 -1
- package/build/src/runtime/store/SharedSdk.d.ts.map +0 -1
- package/build/src/runtime/store/SharedSdk.js.map +0 -1
- package/build/src/runtime/store/StoreSdkNode.d.ts.map +0 -1
- package/build/src/runtime/store/StoreSdkNode.js.map +0 -1
- package/build/src/runtime/store/StoreSdkWeb.d.ts.map +0 -1
- package/build/src/runtime/store/StoreSdkWeb.js.map +0 -1
- package/build/src/runtime/store/TrashSdk.d.ts.map +0 -1
- package/build/src/runtime/store/TrashSdk.js.map +0 -1
- package/build/src/runtime/store/UsersSdk.d.ts.map +0 -1
- package/build/src/runtime/store/UsersSdk.js +0 -104
- package/build/src/runtime/store/UsersSdk.js.map +0 -1
- package/build/src/runtime/store/WsClient.d.ts.map +0 -1
- package/build/src/runtime/store/WsClient.js.map +0 -1
- package/build/src/runtime/store/WsClientNode.d.ts.map +0 -1
- package/build/src/runtime/store/WsClientNode.js.map +0 -1
- package/build/src/runtime/store/WsClientWeb.d.ts.map +0 -1
- package/build/src/runtime/store/WsClientWeb.js.map +0 -1
- package/src/runtime/store/OrganizationsSdk.ts +0 -364
- package/src/runtime/store/UsersSdk.ts +0 -186
- /package/build/src/{runtime/store → sdk}/AuthSdk.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/AuthSdk.js +0 -0
- /package/build/src/{runtime/store → sdk}/Http.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/Http.js +0 -0
- /package/build/src/{runtime/store → sdk}/HttpNode.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/Sdk.js +0 -0
- /package/build/src/{runtime/store → sdk}/StoreSdkNode.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/StoreSdkNode.js +0 -0
- /package/build/src/{runtime/store → sdk}/StoreSdkWeb.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/StoreSdkWeb.js +0 -0
- /package/build/src/{runtime/store → sdk}/WsClient.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/WsClient.js +0 -0
- /package/build/src/{runtime/store → sdk}/WsClientNode.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/WsClientNode.js +0 -0
- /package/build/src/{runtime/store → sdk}/WsClientWeb.d.ts +0 -0
- /package/build/src/{runtime/store → sdk}/WsClientWeb.js +0 -0
- /package/src/{runtime/store → sdk}/AuthSdk.ts +0 -0
- /package/src/{runtime/store → sdk}/Http.ts +0 -0
- /package/src/{runtime/store → sdk}/StoreSdkNode.ts +0 -0
- /package/src/{runtime/store → sdk}/StoreSdkWeb.ts +0 -0
- /package/src/{runtime/store → sdk}/WsClient.ts +0 -0
- /package/src/{runtime/store → sdk}/WsClientNode.ts +0 -0
- /package/src/{runtime/store → sdk}/WsClientWeb.ts +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { SdkBase, SdkOptions } from './SdkBase.js';
|
|
2
|
+
import type { ContextListOptions, ContextListResult } from '../events/BaseEvents.js';
|
|
3
|
+
import type { IOrganization, UserOrganizationGrantType } from '../models/store/Organization.js';
|
|
4
|
+
import type { InvitationSchema } from '../models/store/Invitation.js';
|
|
5
|
+
import type { PatchInfo } from '../patch/types.js';
|
|
6
|
+
import type { IUser } from '../models/store/User.js';
|
|
7
|
+
export declare class OrganizationsSdk extends SdkBase {
|
|
8
|
+
/**
|
|
9
|
+
* Lists all user organizations.
|
|
10
|
+
*/
|
|
11
|
+
list(request?: SdkOptions): Promise<ContextListResult<IOrganization>>;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new organization.
|
|
14
|
+
* @param orgName The name of the organization to create.
|
|
15
|
+
* @param request The request options.
|
|
16
|
+
* @returns A promise that resolves to the created organization.
|
|
17
|
+
*/
|
|
18
|
+
create(orgName: string, request?: SdkOptions): Promise<IOrganization>;
|
|
19
|
+
invitations: {
|
|
20
|
+
/**
|
|
21
|
+
* Lists all invitations for a given organization.
|
|
22
|
+
* @param oid The organization ID.
|
|
23
|
+
* @param request The request options.
|
|
24
|
+
* @returns A promise that resolves to a list of invitations.
|
|
25
|
+
*/
|
|
26
|
+
list: (oid: string, request?: SdkOptions) => Promise<ContextListResult<InvitationSchema>>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates an invitation for a user to join an organization.
|
|
29
|
+
* @param oid The organization ID.
|
|
30
|
+
* @param email The email address of the user to invite.
|
|
31
|
+
* @param grant_type The type of grant for the user.
|
|
32
|
+
* @param name The name of the user (optional).
|
|
33
|
+
* @param request The request options.
|
|
34
|
+
* @returns A promise that resolves to the created invitation.
|
|
35
|
+
*/
|
|
36
|
+
create: (oid: string, email: string, grant_type: UserOrganizationGrantType, name?: string, request?: SdkOptions) => Promise<InvitationSchema>;
|
|
37
|
+
/**
|
|
38
|
+
* Finds an invitation by its token.
|
|
39
|
+
* @param oid The organization ID.
|
|
40
|
+
* @param token The invitation token.
|
|
41
|
+
* @param request The request options.
|
|
42
|
+
* @returns A promise that resolves to the found invitation.
|
|
43
|
+
*/
|
|
44
|
+
findByToken: (oid: string, token: string, request?: SdkOptions) => Promise<InvitationSchema>;
|
|
45
|
+
/**
|
|
46
|
+
* Declines an invitation.
|
|
47
|
+
* @param oid The organization ID.
|
|
48
|
+
* @param id The invitation ID.
|
|
49
|
+
* @param request The request options.
|
|
50
|
+
* @returns A promise that resolves when the invitation is declined.
|
|
51
|
+
*/
|
|
52
|
+
decline: (oid: string, id: string, request?: SdkOptions) => Promise<InvitationSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* Soft-deletes an invitation.
|
|
55
|
+
* @param oid The organization ID.
|
|
56
|
+
* @param id The invitation ID.
|
|
57
|
+
* @param request The request options.
|
|
58
|
+
* @returns A promise that resolves to the deleted invitation.
|
|
59
|
+
*/
|
|
60
|
+
delete: (oid: string, id: string, request?: SdkOptions) => Promise<InvitationSchema>;
|
|
61
|
+
/**
|
|
62
|
+
* Patches an invitation. The server performs the patch validation.
|
|
63
|
+
* The API only allows to patch some of the invitation properties:
|
|
64
|
+
* - name
|
|
65
|
+
* - expires_at
|
|
66
|
+
* - grant_type
|
|
67
|
+
* @param oid The organization ID.
|
|
68
|
+
* @param id The invitation ID.
|
|
69
|
+
* @param info The patch information.
|
|
70
|
+
* @param request The request options.
|
|
71
|
+
* @returns A promise that resolves to the patched invitation.
|
|
72
|
+
*/
|
|
73
|
+
patch: (oid: string, id: string, info: PatchInfo, request?: SdkOptions) => Promise<InvitationSchema>;
|
|
74
|
+
/**
|
|
75
|
+
* Resends an invitation.
|
|
76
|
+
* @param oid The organization ID.
|
|
77
|
+
* @param id The invitation ID.
|
|
78
|
+
* @param request The request options.
|
|
79
|
+
* @returns A promise that resolves to the updated invitation.
|
|
80
|
+
*/
|
|
81
|
+
resend: (oid: string, id: string, request?: SdkOptions) => Promise<InvitationSchema>;
|
|
82
|
+
};
|
|
83
|
+
users: {
|
|
84
|
+
/**
|
|
85
|
+
* Lists users in the organization.
|
|
86
|
+
*
|
|
87
|
+
* @param oid The key of the organization we want to read the user from.
|
|
88
|
+
* @param options Optional query options.
|
|
89
|
+
* @param request Optional request options.
|
|
90
|
+
*/
|
|
91
|
+
list: (oid: string, options?: ContextListOptions, request?: SdkOptions) => Promise<ContextListResult<IUser>>;
|
|
92
|
+
/**
|
|
93
|
+
* Gets a user by its key in the organization.
|
|
94
|
+
*
|
|
95
|
+
* @param oid The key of the organization parent organization.
|
|
96
|
+
* @param key The user key.
|
|
97
|
+
* @param request Optional request options.
|
|
98
|
+
* @returns The user object
|
|
99
|
+
*/
|
|
100
|
+
read: (oid: string, key: string, request?: SdkOptions) => Promise<IUser>;
|
|
101
|
+
/**
|
|
102
|
+
* Activates a user in the organization.
|
|
103
|
+
* If the user is already active the API will respond with an error.
|
|
104
|
+
* @param oid The key of the organization parent organization.
|
|
105
|
+
* @param key The user key.
|
|
106
|
+
*/
|
|
107
|
+
activate: (oid: string, key: string, request?: SdkOptions) => Promise<IUser>;
|
|
108
|
+
/**
|
|
109
|
+
* Deactivates a user in the organization.
|
|
110
|
+
* If the user is already deactivated the API will respond with an error.
|
|
111
|
+
* @param oid The key of the organization parent organization.
|
|
112
|
+
* @param key The user key.
|
|
113
|
+
*/
|
|
114
|
+
deactivate: (oid: string, key: string, request?: SdkOptions) => Promise<IUser>;
|
|
115
|
+
/**
|
|
116
|
+
* Deletes a user from the organization.
|
|
117
|
+
* @param oid The key of the organization parent organization.
|
|
118
|
+
* @param key The user
|
|
119
|
+
* @param request Optional request options.
|
|
120
|
+
* @returns A promise that resolves when the user is deleted.
|
|
121
|
+
*/
|
|
122
|
+
delete: (oid: string, key: string, request?: SdkOptions) => Promise<void>;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=OrganizationsSdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrganizationsSdk.d.ts","sourceRoot":"","sources":["../../../src/sdk/OrganizationsSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAKP,UAAU,EACX,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAA;AAC/F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGpD,qBAAa,gBAAiB,SAAQ,OAAO;IAC3C;;OAEG;IACG,IAAI,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAyB/E;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAkC/E,WAAW;QACT;;;;;WAKG;oBACe,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;QAyBjG;;;;;;;;WAQG;sBAEI,MAAM,SACJ,MAAM,cACD,yBAAyB,SAC9B,MAAM,YACJ,UAAU,KAClB,OAAO,CAAC,gBAAgB,CAAC;QAmC5B;;;;;;WAMG;2BACsB,MAAM,SAAS,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,gBAAgB,CAAC;QAyBpG;;;;;;WAMG;uBACkB,MAAM,MAAM,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,gBAAgB,CAAC;QAwB7F;;;;;;WAMG;sBACiB,MAAM,MAAM,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,gBAAgB,CAAC;QAwB5F;;;;;;;;;;;WAWG;qBACgB,MAAM,MAAM,MAAM,QAAQ,SAAS,YAAW,UAAU,KAAQ,OAAO,CAAC,gBAAgB,CAAC;QA8B5G;;;;;;WAMG;sBACiB,MAAM,MAAM,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,gBAAgB,CAAC;MAuB7F;IAED,KAAK;QACH;;;;;;WAMG;oBAEI,MAAM,YACD,kBAAkB,YACnB,UAAU,KAClB,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QA0BpC;;;;;;;WAOG;oBACe,MAAM,OAAO,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,KAAK,CAAC;QAsBhF;;;;;WAKG;wBACmB,MAAM,OAAO,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,KAAK,CAAC;QAsBpF;;;;;WAKG;0BACqB,MAAM,OAAO,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,KAAK,CAAC;QAsBtF;;;;;;WAMG;sBACiB,MAAM,OAAO,MAAM,YAAW,UAAU,KAAQ,OAAO,CAAC,IAAI,CAAC;MAWlF;CACF"}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { SdkBase, E_RESPONSE_STATUS, E_RESPONSE_NO_VALUE, E_INVALID_JSON, E_RESPONSE_UNKNOWN, } from './SdkBase.js';
|
|
2
|
+
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
|
+
import { Exception } from '../exceptions/exception.js';
|
|
4
|
+
export class OrganizationsSdk extends SdkBase {
|
|
5
|
+
/**
|
|
6
|
+
* Lists all user organizations.
|
|
7
|
+
*/
|
|
8
|
+
async list(request = {}) {
|
|
9
|
+
const { token } = request;
|
|
10
|
+
const url = this.sdk.getUrl(RouteBuilder.organizations());
|
|
11
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
12
|
+
this.inspectCommonStatusCodes(result);
|
|
13
|
+
const E_PREFIX = 'Unable to list your organizations. ';
|
|
14
|
+
if (result.status !== 200) {
|
|
15
|
+
this.logInvalidResponse(result);
|
|
16
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
17
|
+
}
|
|
18
|
+
if (!result.body) {
|
|
19
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
20
|
+
}
|
|
21
|
+
let data;
|
|
22
|
+
try {
|
|
23
|
+
data = JSON.parse(result.body);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
27
|
+
}
|
|
28
|
+
if (!Array.isArray(data.items)) {
|
|
29
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
30
|
+
}
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new organization.
|
|
35
|
+
* @param orgName The name of the organization to create.
|
|
36
|
+
* @param request The request options.
|
|
37
|
+
* @returns A promise that resolves to the created organization.
|
|
38
|
+
*/
|
|
39
|
+
async create(orgName, request = {}) {
|
|
40
|
+
const { token } = request;
|
|
41
|
+
const url = this.sdk.getUrl(RouteBuilder.organizations());
|
|
42
|
+
const body = {
|
|
43
|
+
name: orgName,
|
|
44
|
+
};
|
|
45
|
+
const result = await this.sdk.http.post(url.toString(), {
|
|
46
|
+
body: JSON.stringify(body),
|
|
47
|
+
token,
|
|
48
|
+
headers: {
|
|
49
|
+
'Content-Type': 'application/json',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
this.inspectCommonStatusCodes(result);
|
|
53
|
+
const E_PREFIX = 'Unable to create an organization. ';
|
|
54
|
+
if (result.status !== 200) {
|
|
55
|
+
this.logInvalidResponse(result);
|
|
56
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
57
|
+
}
|
|
58
|
+
if (!result.body) {
|
|
59
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
60
|
+
}
|
|
61
|
+
let data;
|
|
62
|
+
try {
|
|
63
|
+
data = JSON.parse(result.body);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
67
|
+
}
|
|
68
|
+
if (!data.kind) {
|
|
69
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
70
|
+
}
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
invitations = {
|
|
74
|
+
/**
|
|
75
|
+
* Lists all invitations for a given organization.
|
|
76
|
+
* @param oid The organization ID.
|
|
77
|
+
* @param request The request options.
|
|
78
|
+
* @returns A promise that resolves to a list of invitations.
|
|
79
|
+
*/
|
|
80
|
+
list: async (oid, request = {}) => {
|
|
81
|
+
const { token } = request;
|
|
82
|
+
const url = this.sdk.getUrl(RouteBuilder.invitations(oid));
|
|
83
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
84
|
+
this.inspectCommonStatusCodes(result);
|
|
85
|
+
const E_PREFIX = 'Unable to list organization invitations. ';
|
|
86
|
+
if (result.status !== 200) {
|
|
87
|
+
this.logInvalidResponse(result);
|
|
88
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
89
|
+
}
|
|
90
|
+
if (!result.body) {
|
|
91
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
92
|
+
}
|
|
93
|
+
let data;
|
|
94
|
+
try {
|
|
95
|
+
data = JSON.parse(result.body);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
99
|
+
}
|
|
100
|
+
if (!Array.isArray(data.items)) {
|
|
101
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
102
|
+
}
|
|
103
|
+
return data;
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* Creates an invitation for a user to join an organization.
|
|
107
|
+
* @param oid The organization ID.
|
|
108
|
+
* @param email The email address of the user to invite.
|
|
109
|
+
* @param grant_type The type of grant for the user.
|
|
110
|
+
* @param name The name of the user (optional).
|
|
111
|
+
* @param request The request options.
|
|
112
|
+
* @returns A promise that resolves to the created invitation.
|
|
113
|
+
*/
|
|
114
|
+
create: async (oid, email, grant_type, name, request = {}) => {
|
|
115
|
+
const url = this.sdk.getUrl(RouteBuilder.invitations(oid));
|
|
116
|
+
const body = {
|
|
117
|
+
email,
|
|
118
|
+
name,
|
|
119
|
+
grant_type,
|
|
120
|
+
};
|
|
121
|
+
const result = await this.sdk.http.post(url.toString(), {
|
|
122
|
+
body: JSON.stringify(body),
|
|
123
|
+
token: request.token,
|
|
124
|
+
headers: {
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
this.inspectCommonStatusCodes(result);
|
|
129
|
+
const E_PREFIX = 'Unable to create an invitation. ';
|
|
130
|
+
if (result.status !== 200) {
|
|
131
|
+
this.logInvalidResponse(result);
|
|
132
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
133
|
+
}
|
|
134
|
+
if (!result.body) {
|
|
135
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
136
|
+
}
|
|
137
|
+
let data;
|
|
138
|
+
try {
|
|
139
|
+
data = JSON.parse(result.body);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
143
|
+
}
|
|
144
|
+
if (!data.kind) {
|
|
145
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
146
|
+
}
|
|
147
|
+
return data;
|
|
148
|
+
},
|
|
149
|
+
/**
|
|
150
|
+
* Finds an invitation by its token.
|
|
151
|
+
* @param oid The organization ID.
|
|
152
|
+
* @param token The invitation token.
|
|
153
|
+
* @param request The request options.
|
|
154
|
+
* @returns A promise that resolves to the found invitation.
|
|
155
|
+
*/
|
|
156
|
+
findByToken: async (oid, token, request = {}) => {
|
|
157
|
+
const url = this.sdk.getUrl(RouteBuilder.findInvitation(oid));
|
|
158
|
+
url.searchParams.append('token', token);
|
|
159
|
+
const result = await this.sdk.http.get(url.toString(), request);
|
|
160
|
+
this.inspectCommonStatusCodes(result);
|
|
161
|
+
const E_PREFIX = 'Unable to find invitation by token. ';
|
|
162
|
+
if (result.status !== 200) {
|
|
163
|
+
this.logInvalidResponse(result);
|
|
164
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
165
|
+
}
|
|
166
|
+
if (!result.body) {
|
|
167
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
168
|
+
}
|
|
169
|
+
let data;
|
|
170
|
+
try {
|
|
171
|
+
data = JSON.parse(result.body);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
175
|
+
}
|
|
176
|
+
if (!data.kind) {
|
|
177
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
178
|
+
}
|
|
179
|
+
return data;
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* Declines an invitation.
|
|
183
|
+
* @param oid The organization ID.
|
|
184
|
+
* @param id The invitation ID.
|
|
185
|
+
* @param request The request options.
|
|
186
|
+
* @returns A promise that resolves when the invitation is declined.
|
|
187
|
+
*/
|
|
188
|
+
decline: async (oid, id, request = {}) => {
|
|
189
|
+
const url = this.sdk.getUrl(RouteBuilder.declineInvitation(oid, id));
|
|
190
|
+
const result = await this.sdk.http.post(url.toString(), request);
|
|
191
|
+
this.inspectCommonStatusCodes(result);
|
|
192
|
+
const E_PREFIX = 'Unable to decline invitation. ';
|
|
193
|
+
if (result.status !== 200) {
|
|
194
|
+
this.logInvalidResponse(result);
|
|
195
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
196
|
+
}
|
|
197
|
+
if (!result.body) {
|
|
198
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
199
|
+
}
|
|
200
|
+
let data;
|
|
201
|
+
try {
|
|
202
|
+
data = JSON.parse(result.body);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
206
|
+
}
|
|
207
|
+
if (!data.kind) {
|
|
208
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
209
|
+
}
|
|
210
|
+
return data;
|
|
211
|
+
},
|
|
212
|
+
/**
|
|
213
|
+
* Soft-deletes an invitation.
|
|
214
|
+
* @param oid The organization ID.
|
|
215
|
+
* @param id The invitation ID.
|
|
216
|
+
* @param request The request options.
|
|
217
|
+
* @returns A promise that resolves to the deleted invitation.
|
|
218
|
+
*/
|
|
219
|
+
delete: async (oid, id, request = {}) => {
|
|
220
|
+
const url = this.sdk.getUrl(RouteBuilder.invitation(oid, id));
|
|
221
|
+
const result = await this.sdk.http.delete(url.toString(), request);
|
|
222
|
+
this.inspectCommonStatusCodes(result);
|
|
223
|
+
const E_PREFIX = 'Unable to delete invitation. ';
|
|
224
|
+
if (result.status !== 200) {
|
|
225
|
+
this.logInvalidResponse(result);
|
|
226
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
227
|
+
}
|
|
228
|
+
if (!result.body) {
|
|
229
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
230
|
+
}
|
|
231
|
+
let data;
|
|
232
|
+
try {
|
|
233
|
+
data = JSON.parse(result.body);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
237
|
+
}
|
|
238
|
+
if (!data.kind) {
|
|
239
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
240
|
+
}
|
|
241
|
+
return data;
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Patches an invitation. The server performs the patch validation.
|
|
245
|
+
* The API only allows to patch some of the invitation properties:
|
|
246
|
+
* - name
|
|
247
|
+
* - expires_at
|
|
248
|
+
* - grant_type
|
|
249
|
+
* @param oid The organization ID.
|
|
250
|
+
* @param id The invitation ID.
|
|
251
|
+
* @param info The patch information.
|
|
252
|
+
* @param request The request options.
|
|
253
|
+
* @returns A promise that resolves to the patched invitation.
|
|
254
|
+
*/
|
|
255
|
+
patch: async (oid, id, info, request = {}) => {
|
|
256
|
+
const url = this.sdk.getUrl(RouteBuilder.invitation(oid, id));
|
|
257
|
+
const result = await this.sdk.http.patch(url.toString(), {
|
|
258
|
+
body: JSON.stringify(info),
|
|
259
|
+
token: request.token,
|
|
260
|
+
headers: {
|
|
261
|
+
'Content-Type': 'application/json',
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
this.inspectCommonStatusCodes(result);
|
|
265
|
+
const E_PREFIX = 'Unable to update invitation. ';
|
|
266
|
+
if (result.status !== 200) {
|
|
267
|
+
this.logInvalidResponse(result);
|
|
268
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
269
|
+
}
|
|
270
|
+
if (!result.body) {
|
|
271
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
272
|
+
}
|
|
273
|
+
let data;
|
|
274
|
+
try {
|
|
275
|
+
data = JSON.parse(result.body);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
279
|
+
}
|
|
280
|
+
if (!data.kind) {
|
|
281
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
282
|
+
}
|
|
283
|
+
return data;
|
|
284
|
+
},
|
|
285
|
+
/**
|
|
286
|
+
* Resends an invitation.
|
|
287
|
+
* @param oid The organization ID.
|
|
288
|
+
* @param id The invitation ID.
|
|
289
|
+
* @param request The request options.
|
|
290
|
+
* @returns A promise that resolves to the updated invitation.
|
|
291
|
+
*/
|
|
292
|
+
resend: async (oid, id, request = {}) => {
|
|
293
|
+
const url = this.sdk.getUrl(RouteBuilder.resendInvitation(oid, id));
|
|
294
|
+
const result = await this.sdk.http.put(url.toString(), request);
|
|
295
|
+
this.inspectCommonStatusCodes(result);
|
|
296
|
+
const E_PREFIX = 'Unable to resend invitation. ';
|
|
297
|
+
if (result.status !== 200) {
|
|
298
|
+
this.logInvalidResponse(result);
|
|
299
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
300
|
+
}
|
|
301
|
+
if (!result.body) {
|
|
302
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
303
|
+
}
|
|
304
|
+
let data;
|
|
305
|
+
try {
|
|
306
|
+
data = JSON.parse(result.body);
|
|
307
|
+
}
|
|
308
|
+
catch {
|
|
309
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
310
|
+
}
|
|
311
|
+
if (!data.kind) {
|
|
312
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
313
|
+
}
|
|
314
|
+
return data;
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
users = {
|
|
318
|
+
/**
|
|
319
|
+
* Lists users in the organization.
|
|
320
|
+
*
|
|
321
|
+
* @param oid The key of the organization we want to read the user from.
|
|
322
|
+
* @param options Optional query options.
|
|
323
|
+
* @param request Optional request options.
|
|
324
|
+
*/
|
|
325
|
+
list: async (oid, options, request = {}) => {
|
|
326
|
+
const { token } = request;
|
|
327
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUsers(oid));
|
|
328
|
+
this.sdk.appendListOptions(url, options);
|
|
329
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
330
|
+
this.inspectCommonStatusCodes(result);
|
|
331
|
+
const E_PREFIX = 'Unable to list projects. ';
|
|
332
|
+
if (result.status !== 200) {
|
|
333
|
+
this.logInvalidResponse(result);
|
|
334
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
335
|
+
}
|
|
336
|
+
if (!result.body) {
|
|
337
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
338
|
+
}
|
|
339
|
+
let data;
|
|
340
|
+
try {
|
|
341
|
+
data = JSON.parse(result.body);
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
345
|
+
}
|
|
346
|
+
if (!Array.isArray(data.items)) {
|
|
347
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status });
|
|
348
|
+
}
|
|
349
|
+
return data;
|
|
350
|
+
},
|
|
351
|
+
/**
|
|
352
|
+
* Gets a user by its key in the organization.
|
|
353
|
+
*
|
|
354
|
+
* @param oid The key of the organization parent organization.
|
|
355
|
+
* @param key The user key.
|
|
356
|
+
* @param request Optional request options.
|
|
357
|
+
* @returns The user object
|
|
358
|
+
*/
|
|
359
|
+
read: async (oid, key, request = {}) => {
|
|
360
|
+
const { token } = request;
|
|
361
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUser(oid, key));
|
|
362
|
+
const result = await this.sdk.http.get(url.toString(), { token });
|
|
363
|
+
this.inspectCommonStatusCodes(result);
|
|
364
|
+
const E_PREFIX = 'Unable to read the user info. ';
|
|
365
|
+
if (result.status !== 200) {
|
|
366
|
+
this.logInvalidResponse(result);
|
|
367
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
368
|
+
}
|
|
369
|
+
if (!result.body) {
|
|
370
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
371
|
+
}
|
|
372
|
+
let data;
|
|
373
|
+
try {
|
|
374
|
+
data = JSON.parse(result.body);
|
|
375
|
+
}
|
|
376
|
+
catch {
|
|
377
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
378
|
+
}
|
|
379
|
+
return data;
|
|
380
|
+
},
|
|
381
|
+
/**
|
|
382
|
+
* Activates a user in the organization.
|
|
383
|
+
* If the user is already active the API will respond with an error.
|
|
384
|
+
* @param oid The key of the organization parent organization.
|
|
385
|
+
* @param key The user key.
|
|
386
|
+
*/
|
|
387
|
+
activate: async (oid, key, request = {}) => {
|
|
388
|
+
const { token } = request;
|
|
389
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUserActivate(oid, key));
|
|
390
|
+
const result = await this.sdk.http.post(url.toString(), { token });
|
|
391
|
+
this.inspectCommonStatusCodes(result);
|
|
392
|
+
const E_PREFIX = 'Unable to activate the user. ';
|
|
393
|
+
if (result.status !== 200) {
|
|
394
|
+
this.logInvalidResponse(result);
|
|
395
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
396
|
+
}
|
|
397
|
+
if (!result.body) {
|
|
398
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
399
|
+
}
|
|
400
|
+
let data;
|
|
401
|
+
try {
|
|
402
|
+
data = JSON.parse(result.body);
|
|
403
|
+
}
|
|
404
|
+
catch {
|
|
405
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
406
|
+
}
|
|
407
|
+
return data;
|
|
408
|
+
},
|
|
409
|
+
/**
|
|
410
|
+
* Deactivates a user in the organization.
|
|
411
|
+
* If the user is already deactivated the API will respond with an error.
|
|
412
|
+
* @param oid The key of the organization parent organization.
|
|
413
|
+
* @param key The user key.
|
|
414
|
+
*/
|
|
415
|
+
deactivate: async (oid, key, request = {}) => {
|
|
416
|
+
const { token } = request;
|
|
417
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUserDeactivate(oid, key));
|
|
418
|
+
const result = await this.sdk.http.post(url.toString(), { token });
|
|
419
|
+
this.inspectCommonStatusCodes(result);
|
|
420
|
+
const E_PREFIX = 'Unable to deactivate the user. ';
|
|
421
|
+
if (result.status !== 200) {
|
|
422
|
+
this.logInvalidResponse(result);
|
|
423
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
424
|
+
}
|
|
425
|
+
if (!result.body) {
|
|
426
|
+
throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status });
|
|
427
|
+
}
|
|
428
|
+
let data;
|
|
429
|
+
try {
|
|
430
|
+
data = JSON.parse(result.body);
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status });
|
|
434
|
+
}
|
|
435
|
+
return data;
|
|
436
|
+
},
|
|
437
|
+
/**
|
|
438
|
+
* Deletes a user from the organization.
|
|
439
|
+
* @param oid The key of the organization parent organization.
|
|
440
|
+
* @param key The user
|
|
441
|
+
* @param request Optional request options.
|
|
442
|
+
* @returns A promise that resolves when the user is deleted.
|
|
443
|
+
*/
|
|
444
|
+
delete: async (oid, key, request = {}) => {
|
|
445
|
+
const { token } = request;
|
|
446
|
+
const url = this.sdk.getUrl(RouteBuilder.organizationUser(oid, key));
|
|
447
|
+
const result = await this.sdk.http.delete(url.toString(), { token });
|
|
448
|
+
this.inspectCommonStatusCodes(result);
|
|
449
|
+
const E_PREFIX = 'Unable to delete the user. ';
|
|
450
|
+
if (result.status !== 204) {
|
|
451
|
+
this.logInvalidResponse(result);
|
|
452
|
+
throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body);
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
//# sourceMappingURL=OrganizationsSdk.js.map
|