EnvRoleBuilder
Purpose: Initializes the EnvRoleBuilder
with the provided arguments and sets up the initial state. This constructor is private and is used internally by the static methods.
Usage:
The constructor is not called directly. Use the static methods (form
, loadForm
, create
) to create an instance of EnvRoleBuilder
.
addMember
Purpose: Adds a member to the specified role.
Usage:
builder.addMember('contributor', 'memberId');
addIdentity
Purpose: Adds an identity to the specified role.
Usage:
builder.addIdentity('contributor', someIdentityOutput);
pushTo
Purpose: Pushes the environment roles to the specified Key Vault.
Usage:
builder.pushTo({
id: 'vaultId',
name: 'vaultName',
resourceGroupName: 'resourceGroup',
});
grant
Purpose: Grants permissions to the environment roles.
Usage:
builder.grant({
name: 'resourceName',
scope: 'resourceScope',
permissions: { readOnly: true },
});
info
Purpose: Returns the environment roles information.
Usage:
const rolesInfo = builder.info();
console.log(rolesInfo);
form
Purpose: Creates an EnvRoleBuilder
instance from the provided roles.
Usage:
const builder = EnvRoleBuilder.form({
readOnly: { objectId: 'readOnlyId' },
contributor: { objectId: 'contributorId' },
admin: { objectId: 'adminId' },
});
loadForm
Purpose: Loads an EnvRoleBuilder
instance from the specified Key Vault.
Usage:
const builder = EnvRoleBuilder.loadForm({
id: 'vaultId',
name: 'vaultName',
resourceGroupName: 'resourceGroup',
});
create
Purpose: Creates a new EnvRoleBuilder
instance with default roles.
Usage:
const builder = EnvRoleBuilder.create();
Here is a complete example that demonstrates how to use the EnvRoleBuilder
class, ensuring that the build()
method is called at the end:
const builder = EnvRoleBuilder.create();
builder
.addMember('contributor', 'memberId')
.addIdentity('contributor', someIdentityOutput)
.pushTo({
id: 'vaultId',
name: 'vaultName',
resourceGroupName: 'resourceGroup',
})
.grant({
name: 'resourceName',
scope: 'resourceScope',
permissions: { readOnly: true },
});
const rolesInfo = builder.info();
console.log(rolesInfo);
Purpose: Initializes the EnvRoleBuilder
with the provided arguments and sets up the initial state. This constructor is private and is used internally by the static methods.
Usage:
The constructor is not called directly. Use the static methods (form
, loadForm
, create
) to create an instance of EnvRoleBuilder
.
addMember
Purpose: Adds a member to the specified role.
Usage:
builder.addMember('contributor', 'memberId');
addIdentity
Purpose: Adds an identity to the specified role.
Usage:
builder.addIdentity('contributor', someIdentityOutput);
pushTo
Purpose: Pushes the environment roles to the specified Key Vault.
Usage:
builder.pushTo({
id: 'vaultId',
name: 'vaultName',
resourceGroupName: 'resourceGroup',
});
grant
Purpose: Grants permissions to the environment roles.
Usage:
builder.grant({
name: 'resourceName',
scope: 'resourceScope',
permissions: { readOnly: true },
});
info
Purpose: Returns the environment roles information.
Usage:
const rolesInfo = builder.info();
console.log(rolesInfo);
form
Purpose: Creates an EnvRoleBuilder
instance from the provided roles.
Usage:
const builder = EnvRoleBuilder.form({
readOnly: { objectId: 'readOnlyId' },
contributor: { objectId: 'contributorId' },
admin: { objectId: 'adminId' },
});
loadForm
Purpose: Loads an EnvRoleBuilder
instance from the specified Key Vault.
Usage:
const builder = EnvRoleBuilder.loadForm({
id: 'vaultId',
name: 'vaultName',
resourceGroupName: 'resourceGroup',
});
create
Purpose: Creates a new EnvRoleBuilder
instance with default roles.
Usage:
const builder = EnvRoleBuilder.create();
Here is a complete example that demonstrates how to use the EnvRoleBuilder
class, ensuring that the build()
method is called at the end:
const builder = EnvRoleBuilder.create();
builder
.addMember('contributor', 'memberId')
.addIdentity('contributor', someIdentityOutput)
.pushTo({
id: 'vaultId',
name: 'vaultName',
resourceGroupName: 'resourceGroup',
})
.grant({
name: 'resourceName',
scope: 'resourceScope',
permissions: { readOnly: true },
});
const rolesInfo = builder.info();
console.log(rolesInfo);
This example demonstrates how to create an EnvRoleBuilder
instance, configure it with various settings, and finally retrieve the environment roles information. The info()
method is called last to ensure the roles information is fully constructed.