@itwin/access-control-client
Advanced tools
Comparing version
/** @packageDocumentation | ||
* @module AccessControlClient | ||
*/ | ||
import type { IAccessControlClient, IGroupMembersClient, IGroupsClient, IMemberInvitationsClient, IOwnerMembersClient, IPermissionsClient, IRolesClient, IUserMembersClient } from "./accessControlTypes"; | ||
import type { IAccessControlClient, IGroupMembersClient, IGroupsClient, IITwinJobsClient, IMemberInvitationsClient, IOwnerMembersClient, IPermissionsClient, IRolesClient, IUserMembersClient } from "./accessControlTypes"; | ||
export declare class AccessControlClient implements IAccessControlClient { | ||
@@ -13,4 +13,5 @@ permissions: IPermissionsClient; | ||
memberInvitations: IMemberInvitationsClient; | ||
itwinJobs: IITwinJobsClient; | ||
constructor(url?: string); | ||
} | ||
//# sourceMappingURL=AccessControlClient.d.ts.map |
@@ -11,2 +11,3 @@ "use strict"; | ||
const MemberInvitationsClient_1 = require("./subClients/MemberInvitationsClient"); | ||
const ITwinJobsClient_1 = require("./subClients/ITwinJobsClient"); | ||
class AccessControlClient { | ||
@@ -21,2 +22,3 @@ constructor(url) { | ||
this.memberInvitations = new MemberInvitationsClient_1.MemberInvitationsClient(url); | ||
this.itwinJobs = new ITwinJobsClient_1.ITwinJobsClient(url); | ||
} | ||
@@ -23,0 +25,0 @@ } |
@@ -13,2 +13,3 @@ /** @packageDocumentation | ||
memberInvitations: IMemberInvitationsClient; | ||
itwinJobs: IITwinJobsClient; | ||
} | ||
@@ -83,5 +84,18 @@ export interface IPermissionsClient { | ||
} | ||
export interface IITwinJobsClient { | ||
/** Creates a new iTwin Job */ | ||
createITwinJobAsync(accessToken: AccessToken, iTwinId: string, iTwinJobActions: ITwinJobActions): Promise<AccessControlAPIResponse<ITwinJob>>; | ||
/** Gets an iTwin Job. To see errors, pass in the `representation` result mode. */ | ||
getITwinJobAsync(accessToken: AccessToken, iTwinId: string, iTwinJobId?: string, resultMode?: AccessControlResultMode): Promise<AccessControlAPIResponse<ITwinJob>>; | ||
/** Gets the iTwin Job Actions for a specified iTwin Job. */ | ||
getITwinJobActionsAsync(accessToken: AccessToken, iTwinId: string, iTwinJobId?: string): Promise<AccessControlAPIResponse<ITwinJobActions>>; | ||
} | ||
/** | ||
* Optional result mode. Minimal is the default, representation returns extra properties | ||
*/ | ||
export declare type AccessControlResultMode = "minimal" | "representation"; | ||
export interface AccessControlQueryArg { | ||
top?: number; | ||
skip?: number; | ||
resultMode?: AccessControlResultMode; | ||
} | ||
@@ -182,2 +196,26 @@ export interface AccessControlAPIResponse<T> { | ||
} | ||
export declare enum ITwinJobStatus { | ||
Active = "Active", | ||
Complete = "Completed", | ||
PartialCompleted = "PartialCompleted", | ||
Failed = "Failed" | ||
} | ||
/** Contains extra properties with "representation" result mode. | ||
*/ | ||
export interface ITwinJob { | ||
id: string; | ||
itwinId: string; | ||
status: ITwinJobStatus; | ||
error?: ErrorDetail[]; | ||
} | ||
export interface ITwinJobActions { | ||
assignRoles?: ITwinJobAction[]; | ||
unassignRoles?: ITwinJobAction[]; | ||
removeMembers?: Omit<ITwinJobAction, "roleIds">[]; | ||
options?: any; | ||
} | ||
export interface ITwinJobAction { | ||
email: string; | ||
roleIds: string[]; | ||
} | ||
//# sourceMappingURL=accessControlTypes.d.ts.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MemberInvitationStatus = void 0; | ||
exports.ITwinJobStatus = exports.MemberInvitationStatus = void 0; | ||
var MemberInvitationStatus; | ||
@@ -18,3 +18,10 @@ (function (MemberInvitationStatus) { | ||
})(MemberInvitationStatus = exports.MemberInvitationStatus || (exports.MemberInvitationStatus = {})); | ||
var ITwinJobStatus; | ||
(function (ITwinJobStatus) { | ||
ITwinJobStatus["Active"] = "Active"; | ||
ITwinJobStatus["Complete"] = "Completed"; | ||
ITwinJobStatus["PartialCompleted"] = "PartialCompleted"; | ||
ITwinJobStatus["Failed"] = "Failed"; | ||
})(ITwinJobStatus = exports.ITwinJobStatus || (exports.ITwinJobStatus = {})); | ||
//#endregion | ||
//# sourceMappingURL=accessControlTypes.js.map |
/** @packageDocumentation | ||
* @module AccessControlClient | ||
*/ | ||
import type { IAccessControlClient, IGroupMembersClient, IGroupsClient, IMemberInvitationsClient, IOwnerMembersClient, IPermissionsClient, IRolesClient, IUserMembersClient } from "./accessControlTypes"; | ||
import type { IAccessControlClient, IGroupMembersClient, IGroupsClient, IITwinJobsClient, IMemberInvitationsClient, IOwnerMembersClient, IPermissionsClient, IRolesClient, IUserMembersClient } from "./accessControlTypes"; | ||
export declare class AccessControlClient implements IAccessControlClient { | ||
@@ -13,4 +13,5 @@ permissions: IPermissionsClient; | ||
memberInvitations: IMemberInvitationsClient; | ||
itwinJobs: IITwinJobsClient; | ||
constructor(url?: string); | ||
} | ||
//# sourceMappingURL=AccessControlClient.d.ts.map |
@@ -8,2 +8,3 @@ import { PermissionsClient } from "./subClients/PermissionsClient"; | ||
import { MemberInvitationsClient } from "./subClients/MemberInvitationsClient"; | ||
import { ITwinJobsClient } from "./subClients/ITwinJobsClient"; | ||
export class AccessControlClient { | ||
@@ -18,4 +19,5 @@ constructor(url) { | ||
this.memberInvitations = new MemberInvitationsClient(url); | ||
this.itwinJobs = new ITwinJobsClient(url); | ||
} | ||
} | ||
//# sourceMappingURL=AccessControlClient.js.map |
@@ -13,2 +13,3 @@ /** @packageDocumentation | ||
memberInvitations: IMemberInvitationsClient; | ||
itwinJobs: IITwinJobsClient; | ||
} | ||
@@ -83,5 +84,18 @@ export interface IPermissionsClient { | ||
} | ||
export interface IITwinJobsClient { | ||
/** Creates a new iTwin Job */ | ||
createITwinJobAsync(accessToken: AccessToken, iTwinId: string, iTwinJobActions: ITwinJobActions): Promise<AccessControlAPIResponse<ITwinJob>>; | ||
/** Gets an iTwin Job. To see errors, pass in the `representation` result mode. */ | ||
getITwinJobAsync(accessToken: AccessToken, iTwinId: string, iTwinJobId?: string, resultMode?: AccessControlResultMode): Promise<AccessControlAPIResponse<ITwinJob>>; | ||
/** Gets the iTwin Job Actions for a specified iTwin Job. */ | ||
getITwinJobActionsAsync(accessToken: AccessToken, iTwinId: string, iTwinJobId?: string): Promise<AccessControlAPIResponse<ITwinJobActions>>; | ||
} | ||
/** | ||
* Optional result mode. Minimal is the default, representation returns extra properties | ||
*/ | ||
export declare type AccessControlResultMode = "minimal" | "representation"; | ||
export interface AccessControlQueryArg { | ||
top?: number; | ||
skip?: number; | ||
resultMode?: AccessControlResultMode; | ||
} | ||
@@ -182,2 +196,26 @@ export interface AccessControlAPIResponse<T> { | ||
} | ||
export declare enum ITwinJobStatus { | ||
Active = "Active", | ||
Complete = "Completed", | ||
PartialCompleted = "PartialCompleted", | ||
Failed = "Failed" | ||
} | ||
/** Contains extra properties with "representation" result mode. | ||
*/ | ||
export interface ITwinJob { | ||
id: string; | ||
itwinId: string; | ||
status: ITwinJobStatus; | ||
error?: ErrorDetail[]; | ||
} | ||
export interface ITwinJobActions { | ||
assignRoles?: ITwinJobAction[]; | ||
unassignRoles?: ITwinJobAction[]; | ||
removeMembers?: Omit<ITwinJobAction, "roleIds">[]; | ||
options?: any; | ||
} | ||
export interface ITwinJobAction { | ||
email: string; | ||
roleIds: string[]; | ||
} | ||
//# sourceMappingURL=accessControlTypes.d.ts.map |
@@ -14,3 +14,10 @@ /* eslint-disable spaced-comment */ | ||
})(MemberInvitationStatus || (MemberInvitationStatus = {})); | ||
export var ITwinJobStatus; | ||
(function (ITwinJobStatus) { | ||
ITwinJobStatus["Active"] = "Active"; | ||
ITwinJobStatus["Complete"] = "Completed"; | ||
ITwinJobStatus["PartialCompleted"] = "PartialCompleted"; | ||
ITwinJobStatus["Failed"] = "Failed"; | ||
})(ITwinJobStatus || (ITwinJobStatus = {})); | ||
//#endregion | ||
//# sourceMappingURL=accessControlTypes.js.map |
{ | ||
"name": "@itwin/access-control-client", | ||
"version": "3.0.1", | ||
"version": "3.1.0-beta.0", | ||
"description": "Access control client for the iTwin platform", | ||
@@ -5,0 +5,0 @@ "main": "lib/cjs/access-control-client.js", |
@@ -56,3 +56,5 @@ # Access Control Client Library | ||
async function printiTwinRoleIds(): Promise<void> { | ||
const accessControlClient: IAccessControlClient = new AccessControlClient("https://api.bentley.com/accesscontrol/itwins"); | ||
const accessControlClient: IAccessControlClient = new AccessControlClient( | ||
"https://api.bentley.com/accesscontrol/itwins" | ||
); | ||
const accessToken: AccessToken = { get_access_token_logic_here }; | ||
@@ -280,2 +282,3 @@ | ||
``` | ||
### Get list of Owner Members for an iTwin | ||
@@ -386,3 +389,5 @@ | ||
async function printiTwinGroupIds(): Promise<void> { | ||
const accessControlClient: IAccessControlClient = new AccessControlClient("https://api.bentley.com/accesscontrol/itwins"); | ||
const accessControlClient: IAccessControlClient = new AccessControlClient( | ||
"https://api.bentley.com/accesscontrol/itwins" | ||
); | ||
const accessToken: AccessToken = { get_access_token_logic_here }; | ||
@@ -459,3 +464,3 @@ | ||
user: ["John.Johnson@example.com"], | ||
imsGroups: ["Sample IMS Group"] | ||
imsGroups: ["Sample IMS Group"], | ||
}; | ||
@@ -666,4 +671,76 @@ const updateResponse: AccessControlAPIResponse<Group> = | ||
### Create and get iTwin job and related actions | ||
```typescript | ||
import type { AccessToken } from "@itwin/core-bentley"; | ||
import { | ||
AccessControlClient, | ||
IAccessControlClient, | ||
ITwinJob, | ||
ITwinJobActions, | ||
AccessControlAPIResponse, | ||
} from "@itwin/access-control-client"; | ||
/** Function that creates, updates, and deletes a user member. */ | ||
async function printiTwinRole(): Promise<void> { | ||
const accessControlClient: IAccessControlClient = new AccessControlClient(); | ||
const accessToken: AccessToken = { get_access_token_logic_here }; | ||
const itwinJobActions = { | ||
assignRoles: [ | ||
{ | ||
email: "John.Johnson@example.com", | ||
roleIds: ["65819672-962d-4386-8667-136125bcb7b2"], | ||
}, | ||
], | ||
unassignRoles: [ | ||
{ | ||
email: "Maria.Miller@example.com", | ||
roleIds: ["d6a62e34-5016-4bac-a9a0-a6522583698e"], | ||
}, | ||
], | ||
removeMembers: [ | ||
{ | ||
email: "Jobby.McJobface@example.com", | ||
}, | ||
], | ||
}; | ||
// Create iTwin job | ||
const createResponse: AccessControlAPIResponse<ITwinJob> = | ||
await accessControlClient.itwinJobs.createITwinJobAsync( | ||
accessToken, | ||
"d7d82799-3f0c-4175-acbe-cc2573e99359", | ||
itwinJobActions | ||
); | ||
// Get the created iTwin job | ||
const getiTwinJobResponse: AccessControlAPIResponse<ITwinJob> = | ||
await accessControlClient.itwinJobs.getITwinJobAsync( | ||
accessToken, | ||
"d7d82799-3f0c-4175-acbe-cc2573e99359", | ||
createResponse.data.id | ||
); | ||
// Get the created iTwin job with errors | ||
const getiTwinJobResponseWithErrors: AccessControlAPIResponse<ITwinJob> = | ||
await accessControlClient.itwinJobs.getITwinJobAsync( | ||
accessToken, | ||
"d7d82799-3f0c-4175-acbe-cc2573e99359", | ||
createResponse.data.id, | ||
"representation" | ||
); | ||
// Get the created iTwin job's actions | ||
const getiTwinJobActionaResponse: AccessControlAPIResponse<ITwinJobActions> = | ||
await accessControlClient.itwinJobs.getITwinJobActionsAsync( | ||
accessToken, | ||
"d7d82799-3f0c-4175-acbe-cc2573e99359", | ||
createResponse.data.id | ||
); | ||
} | ||
``` | ||
## Contributing to this Repository | ||
For information on how to contribute to this project, please read [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines, [GETTINGSTARTED.md](GETTINGSTARTED.md) for information on working with the documentation in this repository. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
278586
12.73%102
8.51%2131
14.51%742
11.58%2
100%