diff --git a/internal/website/permstable/permstable.go b/internal/website/permstable/permstable.go index 5e788c657..f001e0bb8 100644 --- a/internal/website/permstable/permstable.go +++ b/internal/website/permstable/permstable.go @@ -13,20 +13,16 @@ import ( const permsFile = "website/content/docs/concepts/security/permissions/resource-table.mdx" var ( - iamScopes = []string{"Global", "Org"} - infraScope = []string{"Project"} + iamScopes = []string{"Global", "Org"} + infraScope = []string{"Project"} + tableHeaders = []string{ + "API endpoint", + "Parameters into permissions engine", + "Available actions / examples", + } ) -type Table struct { - Header *Header - Body *Body -} - -type Header struct { - Titles []string -} - -type Body struct { +type Page struct { Resources []*Resource } @@ -48,23 +44,12 @@ type Action struct { Examples []string } -var table = &Table{ - Header: &Header{ - Titles: []string{ - "Resource Type", - "Applicable Scopes", - "API Endpoint", - "Parameters into Permissions Engine", - "Available Actions / Examples", - }, - }, - Body: &Body{ - Resources: make([]*Resource, 0, 12), - }, +var page = &Page{ + Resources: make([]*Resource, 0, 12), } func main() { - table.Body.Resources = append(table.Body.Resources, + page.Resources = append(page.Resources, account, authMethod, authToken, @@ -114,9 +99,10 @@ func main() { post = append(post, lines[i]) } - final := fmt.Sprintf("%s\n\n%s\n\n%s", + final := fmt.Sprintf("%s\n\n%s\n\n%s\n\n%s", strings.Join(pre, "\n"), - strings.Join(table.Marshal(), "\n"), + strings.Join(page.MarshalTableOfContents(), "\n"), + strings.Join(page.MarshalBody(), "\n"), strings.Join(post, "\n")) if err := os.WriteFile(permsFile, []byte(final), 0o644); err != nil { @@ -125,121 +111,107 @@ func main() { } } -func (t *Table) Marshal() (ret []string) { - ret = append(ret, "
%s`, indent(8), escape(e.Path)),
- fmt.Sprintf(`%s%s", escape(e.Path)))
+
+ // Parameters Field
+ pString := "%s`, indent(14), escape(e.Params[v])),
- fmt.Sprintf(`%s%s%s: %s`, indent(12), v.Name, v.Description),
- fmt.Sprintf(`%s%s: %s%s`, indent(14), escape(x)),
- fmt.Sprintf(`%s| Resource Type | -Applicable Scopes | -API Endpoint | -Parameters into Permissions Engine | -Available Actions / Examples | -
|---|---|---|---|---|
| Account | -
-
|
-
- /accounts
- |
-
-
|
-
-
|
-
- /accounts/<id>
- |
-
-
|
-
-
|
- ||
| Auth Method | -
-
|
-
- /auth-methods
- |
-
-
|
-
-
|
-
- /auth-methods/<id>
- |
-
-
|
-
-
|
- ||
| Auth Token | -
-
|
-
- /auth-tokens
- |
-
-
|
-
-
|
-
- /auth-tokens/<id>
- |
-
-
|
-
-
|
- ||
| Group | -
-
|
-
- /groups
- |
-
-
|
-
-
|
-
- /groups/<id>
- |
-
-
|
-
-
|
- ||
| Host | -
-
|
-
- /hosts
- |
-
-
|
-
-
|
-
- /hosts/<id>
- |
-
-
|
-
-
|
- ||
| Host Catalog | -
-
|
-
- /host-catalogs
- |
-
-
|
-
-
|
-
- /host-catalogs/<id>
- |
-
-
|
-
-
|
- ||
| Host Set | -
-
|
-
- /host-sets
- |
-
-
|
-
-
|
-
- /host-sets/<id>
- |
-
-
|
-
-
|
- ||
| Managed Group | -
-
|
-
- /managed-groups
- |
-
-
|
-
-
|
-
- /managed-groups/<id>
- |
-
-
|
-
-
|
- ||
| Role | -
-
|
-
- /roles
- |
-
-
|
-
-
|
-
- /roles/<id>
- |
-
-
|
-
-
|
- ||
| Scope | -
-
|
-
- /scopes
- |
-
-
|
-
-
|
-
- /scopes/<id>
- |
-
-
|
-
-
|
- ||
| Session | -
-
|
-
- /sessions
- |
-
-
|
-
-
|
-
- /session/<id>
- |
-
-
|
-
-
|
- ||
| Session Recording | -
-
|
-
- /session-recordings
- |
-
-
|
-
-
|
-
- /session-recordings/<id>
- |
-
-
|
-
-
|
- ||
| Storage Bucket | -
-
|
-
- /storage-buckets
- |
-
-
|
-
-
|
-
- /storage-buckets/<id>
- |
-
-
|
-
-
|
- ||
| Target | -
-
|
-
- /targets
- |
-
-
|
-
-
|
-
- /targets/<id>
- |
-
-
|
-
-
|
- ||
| User | -
-
|
-
- /users
- |
-
-
|
-
-
|
-
- /users/<id>
- |
-
-
|
-
-
|
- ||
| Worker | -
-
|
-
- /workers
- |
-
-
|
-
-
|
-
- /workers/<id>
- |
-
-
|
-
-
|
-
/accounts | accountcreate: Create an accountlist: List accounts/accounts/<id> | <id><auth-method-id>accountread: Read an accountupdate: Update an accountdelete: Delete an accountset-password: Set a password on an account, without requiring the current passwordchange-password: Change a password on an account given the current password/auth-methods | auth-methodcreate: Create an auth methodlist: List auth methods/auth-methods/<id> | <id>auth-methodread: Read an auth methodupdate: Update an auth methoddelete: Delete an auth methodauthenticate: Authenticate to an auth method/auth-tokens | auth-tokenlist: List auth tokens/auth-tokens/<id> | <id>auth-tokenread: Read an auth tokendelete: Delete an auth token/groups | groupcreate: Create a grouplist: List groups/groups/<id> | <id>groupread: Read a groupupdate: Update a groupdelete: Delete a groupadd-members: Add members to a groupset-members: Set the full set of members on a groupremove-members: Remove members from a group/hosts | hostcreate: Create a hostlist: List hosts/hosts/<id> | <id><host-catalog-id>hostread: Read a hostupdate: Update a hostdelete: Delete a host/host-catalogs | host-catalogcreate: Create a host cataloglist: List host catalogs/host-catalogs/<id> | <id>host-catalogread: Read a host catalogupdate: Update a host catalogdelete: Delete a host catalog/host-sets | host-setcreate: Create a host setlist: List host sets/host-sets/<id> | <id><host-catalog-id>host-setread: Read a host setupdate: Update a host setdelete: Delete a host setadd-hosts: Add hosts to a host-setset-hosts: Set the full set of hosts on a host setremove-hosts: Remove hosts from a host set/managed-groups | managed-groupcreate: Create a managed grouplist: List managed groups/managed-groups/<id> | <id><auth-method-id>managed-groupread: Read a managed groupupdate: Update a managed groupdelete: Delete a managed group/roles | rolecreate: Create a rolelist: List roles/roles/<id> | <id>roleread: Read a roleupdate: Update a roledelete: Delete a roleadd-principals: Add principals to a roleset-principals: Set the full set of principals on a roleremove-principals: Remove principals from a roleadd-grants: Add grants to a roleset-grants: Set the full set of grants on a roleremove-grants: Remove grants from a role/scopes | scopecreate: Create a scopelist: List scopes/scopes/<id> | <id>scoperead: Read a scopeupdate: Update a scopedelete: Delete a scope/sessions | sessionlist: List sessions/session/<id> | <id>sessionread: Read a sessioncancel: Cancel a sessionread:self: Read a session, which must be associated with the calling usercancel:self: Cancel a session, which must be associated with the calling user/session-recordings | session-recordinglist: List session recordings/session-recordings/<id> | <id>session-recordingread: Read a session recordingdownload: Download a session recordingreapply-storage-policy: Reapply the storage policy to a session recordingdelete: Delete a session recording/storage-buckets | storage-bucketcreate: Create a storage bucketlist: List storage buckets/storage-buckets/<id> | <id>storage-bucketread: Read a storage bucketupdate: Update a storage bucketdelete: Delete a storage bucket/targets | targetcreate: Create a targetlist: List targets/targets/<id> | <id>targetread: Read a targetupdate: Update a targetdelete: Delete a targetadd-host-sources: Add host sources to a targetset-host-sources: Set the full set of host sources on a targetremove-host-sources: Remove host sources from a targetadd-credential-sources: Add credential sources to a targetset-credential-sources: Set the full set of credential sources on a targetremove-credential-sources: Remove credential sources from a targetauthorize-session: Authorize a session via the target/users | usercreate: Create a userlist: List users/users/<id> | <id>userread: Read a userupdate: Update a userdelete: Delete a useradd-accounts: Add accounts to a userset-accounts: Set the full set of accounts on a userremove-accounts: Remove accounts from a user/workers | workerlist: List workerscreate:controller-led: Create a worker using the controller-led workflowcreate:worker-led: Create a worker using the worker-led workflow/workers/<id> | <id>workerread: Read a workerupdate: Update a workerdelete: Delete a worker