You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui/packages/consul-ui/app/models/token.js

53 lines
1.3 KiB

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import { MANAGEMENT_ID } from 'consul-ui/models/policy';
export const PRIMARY_KEY = 'uid';
export const SLUG_KEY = 'AccessorID';
export default class Token extends Model {
@attr('string') uid;
@attr('string') AccessorID;
@attr('string') Datacenter;
@attr('string') Namespace;
@attr('string') Partition;
@attr('string') IDPName;
@attr('string') SecretID;
@attr('boolean') Legacy;
@attr('boolean') Local;
@attr('string', { defaultValue: () => '' }) Description;
@attr() meta; // {}
@attr({ defaultValue: () => [] }) Policies;
@attr({ defaultValue: () => [] }) Roles;
@attr({ defaultValue: () => [] }) ServiceIdentities;
@attr({ defaultValue: () => [] }) NodeIdentities;
@attr('date') CreateTime;
@attr('string') Hash;
@attr('number') CreateIndex;
@attr('number') ModifyIndex;
// Legacy
@attr('string') Type;
@attr('string', { defaultValue: () => '' }) Name;
@attr('string') Rules;
// End Legacy
@computed('Policies.[]')
get isGlobalManagement() {
return (this.Policies || []).find((item) => item.ID === MANAGEMENT_ID);
}
@computed('SecretID')
get hasSecretID() {
return this.SecretID !== '' && this.SecretID !== '<hidden>';
}
}