Skip to content

Roles support #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

bkimbrough88
Copy link

Enabling the SDK to perform CRUD operations on Roles as well as manage permissions and users on those roles.

Fixes: #307

@bkimbrough88 bkimbrough88 force-pushed the ISSUE-307-roles-support branch from f555caa to d1f37b3 Compare March 13, 2020 04:24
@sendqueery
Copy link
Contributor

sendqueery commented Mar 20, 2020

This looks good, but appears to be missing support for scoping unless I've missed something?
It looks like it's missing from the API docs, but is mentioned elsewhere in Datadog's docs: https://docs.datadoghq.com/account_management/faq/managing-global-role-permissions/?tab=datadogussite#granting-permissions-within-limited-scopes

From their example:

{
    "data": {
        "type": "permissions",
         "id": <PERMISSION_UUID>,
         "scope": {
             "indexes": [
                 "main",
                 "support"
            ]
        }
    }
}

@bkimbrough88
Copy link
Author

You're right, I've added permission scope to the grant permission requests

Data *Organization `json:"data,omitempty"`
}

// TODO: Fill this out with everything you can get back when getting an organization
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a comment that there's much more to Organizations than an ID, but that's all I needed for this implementation. I can easily delete the comment or create an issue for adding Organizations support.

Copy link

@pietdaniel pietdaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry that it is a bit early for the role permission API to be solidified in the public client. Can we postpone implementing this API while we roadmap the APIs definition internally. Roles Users and Permissions are good to go.

roles.go Outdated
Comment on lines 11 to 16
SortNameAsc Sort = "name"
SortNameDesc Sort = "-name"
SortModifiedAtAsc Sort = "modified_at"
SortModifiedAtDesc Sort = "-modified_at"
SortUserCountAsc Sort = "user_count"
SortUserCountDesc Sort = "-user_count"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding SortRolesBy...?

@bkimbrough88
Copy link
Author

I worry that it is a bit early for the role permission API to be solidified in the public client. Can we postpone implementing this API while we roadmap the APIs definition internally. Roles Users and Permissions are good to go.

I feel like anything posted in https://docs.datadoghq.com/api should be stable enough to write into an SDK. The caveat being that you then have to maintain that feature in the SDK as the API evolves.

permissions.go Outdated
permissionRequest := Permission{
Type: String("permissions"),
Id: String(permissionId),
Scope: scope,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the confusion - after investigation earlier we realized the Roles V2 API does not currently support Scope. To use Scope you should use the Roles V1 API.

}
}

func TestClient_GrantScopedRolePermission(t *testing.T) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like above, to use Scoped Permissions you should test against the Roles V1 API.

@bkimbrough88
Copy link
Author

Apologies on letting this sit, I'll take care of the PR comments later tonight

Brandon Kimbrough added 10 commits May 29, 2020 11:40
* Added code to allow for performing CRUD operations on a role
* Added code to allow granting and revoking permissions on a role
* Added code to add or remove users on a role
* Initial unit tests
* Added remaining role CRUD tests
* Added permissions tests
* Ensuring all role methods have at least one unit test
* Splitting permissions and organizations data types and methods into their own files
These files should not have ever been added
Also enhancing git ignore file to ensure other useless files don't get added
* Removed unnecessary print statement
* Reverted git ignore to previous state, will open a new PR with those changes
@bkimbrough88 bkimbrough88 force-pushed the ISSUE-307-roles-support branch from ea5e21f to d380491 Compare June 10, 2020 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for roles
5 participants