vault/ui/app/models/oidc/assignment.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

47 lines
1.2 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import Model, { attr } from '@ember-data/model';
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
import { withModelValidations } from 'vault/decorators/model-validations';
import { isPresent } from '@ember/utils';
const validations = {
name: [
{ type: 'presence', message: 'Name is required.' },
{
type: 'containsWhiteSpace',
message: 'Name cannot contain whitespace.',
},
],
targets: [
{
validator(model) {
return isPresent(model.entityIds) || isPresent(model.groupIds);
},
message: 'At least one entity or group is required.',
},
],
};
@withModelValidations(validations)
export default class OidcAssignmentModel extends Model {
@attr('string') name;
@attr('array') entityIds;
@attr('array') groupIds;
// CAPABILITIES
@lazyCapabilities(apiPath`identity/oidc/assignment/${'name'}`, 'name') assignmentPath;
get canRead() {
return this.assignmentPath.get('canRead');
}
get canEdit() {
return this.assignmentPath.get('canUpdate');
}
get canDelete() {
return this.assignmentPath.get('canDelete');
}
}