Grant management added to Roles API and SDK (#185)

* Adding grants related methods to Roles.

* Adding grants back after the merge of Principals.

* Adding tests for Grant related custom methods.

* Improving api handler methods.

* Fixing tests and sdk field.

* Adding todos for adding principals and grants to List and Update Role responses.

* Fix up Set* tests and fix SetPrincipals bug.

* Making AddPrincipals and RemovePrincipals similar to the tests for AddGrants and RemoveGrants.

* Add JSON grants to output (#187)

I also changed canonical_grants to grants_canonical and used
grants_json. I believe that when members are simply different formats of
other members this is the preferred way to have it in the API. Let me
know if you disagree and we can dig in more.

* Regenerate the API role resource.

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
This commit is contained in:
Todd KnightandJeff Mitchell authored and GitHub committed 2020-07-10 17:42:47 -07:00
1 parent 260703febe
commit 847ca1cc78
19 files changed
+3321 -732

No files matched your search

+367
View File
@@ -2199,6 +2199,51 @@
]
}
},
"/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:add-grants": {
"post": {
"summary": "Adds grants to a role",
"operationId": "RoleService_AddRoleGrants2",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"parameters": [
{
"name": "org_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "project_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "role_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controller.api.services.v1.AddRoleGrantsRequest"
}
}
],
"tags": [
"controller.api.services.v1.RoleService"
]
}
},
"/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:add-principals": {
"post": {
"summary": "Adds Users and/or Groups to a Role",
@@ -2244,6 +2289,51 @@
]
}
},
"/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:remove-grants": {
"post": {
"summary": "Removes grants from a role.",
"operationId": "RoleService_RemoveRoleGrants2",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"parameters": [
{
"name": "org_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "project_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "role_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controller.api.services.v1.RemoveRoleGrantsRequest"
}
}
],
"tags": [
"controller.api.services.v1.RoleService"
]
}
},
"/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:remove-principals": {
"post": {
"summary": "Removes the specified Users and/or Groups from a Role.",
@@ -2289,6 +2379,51 @@
]
}
},
"/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:set-grants": {
"post": {
"summary": "Set grants for a role, removing any grants that are not specified in the request.",
"operationId": "RoleService_SetRoleGrants2",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"parameters": [
{
"name": "org_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "project_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "role_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controller.api.services.v1.SetRoleGrantsRequest"
}
}
],
"tags": [
"controller.api.services.v1.RoleService"
]
}
},
"/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:set-principals": {
"post": {
"summary": "Set Users and/or Groups to a Role, removing any principals that are not specified in the request.",
@@ -2517,6 +2652,45 @@
]
}
},
"/v1/orgs/{org_id}/roles/{role_id}:add-grants": {
"post": {
"summary": "Adds grants to a role",
"operationId": "RoleService_AddRoleGrants",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"parameters": [
{
"name": "org_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "role_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controller.api.services.v1.AddRoleGrantsRequest"
}
}
],
"tags": [
"controller.api.services.v1.RoleService"
]
}
},
"/v1/orgs/{org_id}/roles/{role_id}:add-principals": {
"post": {
"summary": "Adds Users and/or Groups to a Role",
@@ -2556,6 +2730,45 @@
]
}
},
"/v1/orgs/{org_id}/roles/{role_id}:remove-grants": {
"post": {
"summary": "Removes grants from a role.",
"operationId": "RoleService_RemoveRoleGrants",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"parameters": [
{
"name": "org_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "role_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controller.api.services.v1.RemoveRoleGrantsRequest"
}
}
],
"tags": [
"controller.api.services.v1.RoleService"
]
}
},
"/v1/orgs/{org_id}/roles/{role_id}:remove-principals": {
"post": {
"summary": "Removes the specified Users and/or Groups from a Role.",
@@ -2595,6 +2808,45 @@
]
}
},
"/v1/orgs/{org_id}/roles/{role_id}:set-grants": {
"post": {
"summary": "Set grants for a role, removing any grants that are not specified in the request.",
"operationId": "RoleService_SetRoleGrants",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"parameters": [
{
"name": "org_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "role_id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/controller.api.services.v1.SetRoleGrantsRequest"
}
}
],
"tags": [
"controller.api.services.v1.RoleService"
]
}
},
"/v1/orgs/{org_id}/roles/{role_id}:set-principals": {
"post": {
"summary": "Set Users and/or Groups to a Role, removing any principals that are not specified in the request.",
@@ -3153,6 +3405,22 @@
},
"description": "The grants that this role provides for it's principals.\nOutput only.",
"readOnly": true
},
"grants_canonical": {
"type": "array",
"items": {
"type": "string"
},
"description": "The canonical version of the grants in the grants field with the same index.\nOutput only.",
"readOnly": true
},
"grants_json": {
"type": "array",
"items": {
"type": "string"
},
"description": "The JSON version of the grants in the grants field with the same index.\nOutput only.",
"readOnly": true
}
},
"title": "Role contains all fields related to a Role resource"
@@ -3260,6 +3528,39 @@
},
"title": "User contains all fields related to a User resource"
},
"controller.api.services.v1.AddRoleGrantsRequest": {
"type": "object",
"properties": {
"org_id": {
"type": "string"
},
"project_id": {
"type": "string"
},
"role_id": {
"type": "string"
},
"version": {
"type": "integer",
"format": "int64",
"description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail."
},
"grants": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"controller.api.services.v1.AddRoleGrantsResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"controller.api.services.v1.AddRolePrincipalsRequest": {
"type": "object",
"properties": {
@@ -3638,6 +3939,39 @@
"controller.api.services.v1.RemoveFromHostSetResponse": {
"type": "object"
},
"controller.api.services.v1.RemoveRoleGrantsRequest": {
"type": "object",
"properties": {
"org_id": {
"type": "string"
},
"project_id": {
"type": "string"
},
"role_id": {
"type": "string"
},
"version": {
"type": "integer",
"format": "int64",
"description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail."
},
"grants": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"controller.api.services.v1.RemoveRoleGrantsResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"controller.api.services.v1.RemoveRolePrincipalsRequest": {
"type": "object",
"properties": {
@@ -3677,6 +4011,39 @@
}
}
},
"controller.api.services.v1.SetRoleGrantsRequest": {
"type": "object",
"properties": {
"org_id": {
"type": "string"
},
"project_id": {
"type": "string"
},
"role_id": {
"type": "string"
},
"version": {
"type": "integer",
"format": "int64",
"description": "The version ensures the role hasn't changed since it was last retrieved and if\nit has the request will fail."
},
"grants": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"controller.api.services.v1.SetRoleGrantsResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/controller.api.resources.roles.v1.Role"
}
}
},
"controller.api.services.v1.SetRolePrincipalsRequest": {
"type": "object",
"properties": {