From 759c1f555513cae2f411980ce793b325a8edc9b2 Mon Sep 17 00:00:00 2001 From: Cameron Perera Date: Thu, 12 Mar 2026 16:01:02 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20add=20grant=20schema=20t?= =?UTF-8?q?o=20mirage=20(#3196)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 🎸 add grant schema to mirage * refactor: 💡 update grant schema mirage data * refactor: 💡 fix route name in mirage --- addons/api/app/mirage/config.js | 5 + addons/api/app/mirage/data/grants-schema.js | 253 ++++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 addons/api/app/mirage/data/grants-schema.js diff --git a/addons/api/app/mirage/config.js b/addons/api/app/mirage/config.js index be86b60f8..47bc0b32f 100644 --- a/addons/api/app/mirage/config.js +++ b/addons/api/app/mirage/config.js @@ -11,6 +11,7 @@ import initializeMockDesktopContextBridgeAPI from './scenarios/ipc/desktop-conte import makeBooleanFilter from './helpers/bexpr-filter'; import { faker } from '@faker-js/faker'; import { asciicasts } from './data/asciicasts'; +import { grantsSchemaData } from './data/grants-schema'; import { TYPE_WORKER_PKI } from 'api/models/worker'; import environmentConfig from 'ember-get-config'; @@ -210,6 +211,10 @@ function routes() { return metadata; }); + this.get('/grants-schema.json', () => { + return grantsSchemaData; + }); + // make this `/api`, for example, if your API is namespaced this.namespace = environmentConfig.api?.namespace; // delay for each request, automatically set to 0 during testing diff --git a/addons/api/app/mirage/data/grants-schema.js b/addons/api/app/mirage/data/grants-schema.js new file mode 100644 index 000000000..84afa8ddf --- /dev/null +++ b/addons/api/app/mirage/data/grants-schema.js @@ -0,0 +1,253 @@ +/** + * Copyright IBM Corp. 2021, 2026 + * SPDX-License-Identifier: BUSL-1.1 + */ + +export const grantsSchemaData = { + resource_types: [ + { + type: 'auth-method', + collection_actions: ['create', 'list'], + id_actions: ['change-state', 'authenticate', 'read', 'update', 'delete'], + scopes: ['global', 'org'], + id_prefixes: ['ampw', 'amoidc', 'amldap'], + }, + { + type: 'account', + collection_actions: ['create', 'list'], + id_actions: [ + 'set-password', + 'change-password', + 'read', + 'update', + 'delete', + ], + scopes: ['global', 'org'], + id_prefixes: ['acctoidc', 'acctldap', 'apw', 'acctpw'], + parent_type: 'auth-method', + }, + { + type: 'host', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['project'], + id_prefixes: ['hst', 'hplg', 'h'], + parent_type: 'host-catalog', + }, + { + type: 'session', + collection_actions: ['list'], + id_actions: ['read', 'read:self', 'cancel', 'cancel:self'], + scopes: ['project'], + id_prefixes: ['s'], + }, + { + type: 'credential-store', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['project'], + id_prefixes: ['csst', 'cs', 'csvlt'], + }, + { + type: 'alias', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['global'], + id_prefixes: ['alt'], + }, + { + type: 'user', + collection_actions: ['create', 'list'], + id_actions: [ + 'list-resolvable-aliases', + 'read', + 'update', + 'delete', + 'add-accounts', + 'set-accounts', + 'remove-accounts', + ], + scopes: ['global', 'org'], + id_prefixes: ['u'], + }, + { + type: 'auth-token', + collection_actions: ['list'], + id_actions: ['read', 'read:self', 'delete', 'delete:self'], + scopes: ['global', 'org'], + id_prefixes: ['at'], + }, + { + type: 'target', + collection_actions: ['list', 'create'], + id_actions: [ + 'add-credential-sources', + 'remove-credential-sources', + 'delete', + 'set-host-sources', + 'set-credential-sources', + 'authorize-session', + 'read', + 'update', + 'add-host-sources', + 'remove-host-sources', + ], + scopes: ['project'], + id_prefixes: ['trdp', 'ttcp', 'tssh'], + }, + { + type: 'worker', + collection_actions: [ + 'create:controller-led', + 'create:worker-led', + 'list', + 'read-certificate-authority', + 'reinitialize-certificate-authority', + ], + id_actions: [ + 'set-worker-tags', + 'remove-worker-tags', + 'read', + 'update', + 'delete', + 'add-worker-tags', + ], + scopes: ['global'], + id_prefixes: ['w'], + }, + { + type: 'managed-group', + collection_actions: ['create', 'list'], + id_actions: ['update', 'delete', 'read'], + scopes: ['global', 'org'], + id_prefixes: ['mgoidc', 'mgldap'], + parent_type: 'auth-method', + }, + { + type: 'credential-library', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['project'], + id_prefixes: ['clvllt', 'clvsclt', 'clvlt'], + parent_type: 'credential-store', + }, + { + type: 'credential', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['project'], + id_prefixes: [ + 'credupd', + 'credp', + 'credspk', + 'cdvlt', + 'credjson', + 'cred', + 'credup', + ], + parent_type: 'credential-store', + }, + { + type: 'group', + collection_actions: ['create', 'list'], + id_actions: [ + 'update', + 'delete', + 'add-members', + 'set-members', + 'remove-members', + 'read', + ], + scopes: ['global', 'org', 'project'], + id_prefixes: ['g'], + }, + { + type: 'role', + collection_actions: ['create', 'list'], + id_actions: [ + 'add-grant-scopes', + 'update', + 'add-principals', + 'add-grants', + 'set-grant-scopes', + 'remove-grant-scopes', + 'read', + 'delete', + 'set-principals', + 'remove-principals', + 'set-grants', + 'remove-grants', + ], + scopes: ['global', 'org', 'project'], + id_prefixes: ['r'], + }, + { + type: 'host-catalog', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['project'], + id_prefixes: ['hcst', 'hc', 'hcplg'], + }, + { + type: 'host-set', + collection_actions: ['create', 'list'], + id_actions: [ + 'delete', + 'add-hosts', + 'set-hosts', + 'remove-hosts', + 'read', + 'update', + ], + scopes: ['project'], + id_prefixes: ['hsst', 'hsplg', 'hs'], + parent_type: 'host-catalog', + }, + { + type: 'storage-bucket', + collection_actions: ['list', 'create'], + id_actions: ['read', 'update', 'delete'], + scopes: ['global', 'org'], + id_prefixes: ['sb'], + }, + { + type: 'policy', + collection_actions: ['create', 'list'], + id_actions: ['read', 'update', 'delete'], + scopes: ['global', 'org'], + id_prefixes: ['pst'], + }, + { + type: 'billing', + collection_actions: ['monthly-active-users'], + scopes: ['global'], + }, + { + type: 'scope', + collection_actions: [ + 'destroy-key-version', + 'create', + 'list', + 'list-keys', + 'rotate-keys', + 'list-key-version-destruction-jobs', + ], + id_actions: [ + 'attach-storage-policy', + 'detach-storage-policy', + 'read', + 'update', + 'delete', + ], + scopes: ['global', 'org', 'project'], + id_prefixes: ['o', 'global', 'p'], + }, + { + type: 'session-recording', + collection_actions: ['list'], + id_actions: ['read', 'download', 'delete', 'reapply-storage-policy'], + scopes: ['global', 'org'], + id_prefixes: ['sr'], + }, + ], +};