Skip to content
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

Add role relationships to RoleUpdateData #1138

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2022-08-29 18:00:32.163621",
"spec_repo_commit": "45d7cbaa"
"regenerated": "2022-08-29 18:11:44.465510",
"spec_repo_commit": "95e8a34f"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-08-29 18:00:32.176205",
"spec_repo_commit": "45d7cbaa"
"regenerated": "2022-08-29 18:11:44.477822",
"spec_repo_commit": "95e8a34f"
}
}
}
2 changes: 2 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6527,6 +6527,8 @@ components:
description: The unique identifier of the role.
example: 00000000-0000-1111-0000-000000000000
type: string
relationships:
$ref: '#/components/schemas/RoleRelationships'
type:
$ref: '#/components/schemas/RolesType'
required:
Expand Down
17 changes: 17 additions & 0 deletions examples/v2/roles/UpdateRole.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.permissions_type import PermissionsType
from datadog_api_client.v2.model.relationship_to_permission_data import RelationshipToPermissionData
from datadog_api_client.v2.model.relationship_to_permissions import RelationshipToPermissions
from datadog_api_client.v2.model.role_relationships import RoleRelationships
from datadog_api_client.v2.model.role_update_attributes import RoleUpdateAttributes
from datadog_api_client.v2.model.role_update_data import RoleUpdateData
from datadog_api_client.v2.model.role_update_request import RoleUpdateRequest
Expand All @@ -14,13 +18,26 @@
ROLE_DATA_ATTRIBUTES_NAME = environ["ROLE_DATA_ATTRIBUTES_NAME"]
ROLE_DATA_ID = environ["ROLE_DATA_ID"]

# there is a valid "permission" in the system
PERMISSION_ID = environ["PERMISSION_ID"]

body = RoleUpdateRequest(
data=RoleUpdateData(
id=ROLE_DATA_ID,
type=RolesType("roles"),
attributes=RoleUpdateAttributes(
name="developers-updated",
),
relationships=RoleRelationships(
permissions=RelationshipToPermissions(
data=[
RelationshipToPermissionData(
id=PERMISSION_ID,
type=PermissionsType("permissions"),
),
],
),
),
),
)

Expand Down
6 changes: 6 additions & 0 deletions src/datadog_api_client/v2/model/role_update_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ class RoleUpdateData(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.role_update_attributes import RoleUpdateAttributes
from datadog_api_client.v2.model.role_relationships import RoleRelationships
from datadog_api_client.v2.model.roles_type import RolesType

return {
"attributes": (RoleUpdateAttributes,),
"id": (str,),
"relationships": (RoleRelationships,),
"type": (RolesType,),
}

attribute_map = {
"attributes": "attributes",
"id": "id",
"relationships": "relationships",
"type": "type",
}

Expand All @@ -37,6 +40,9 @@ def __init__(self, attributes, id, type, *args, **kwargs):
:param id: The unique identifier of the role.
:type id: str

:param relationships: Relationships of the role object.
:type relationships: RoleRelationships, optional

:param type: Roles type.
:type type: RolesType
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-08-26T21:57:22.524Z

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-05-12T09:53:03.947Z
2022-08-26T21:57:23.791Z

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-01-06T00:52:07.704Z
2022-08-26T21:57:24.361Z

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-05-12T09:53:05.495Z
2022-08-26T21:57:24.588Z

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions tests/v2/features/roles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -262,37 +262,42 @@ Feature: Roles
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/team-aaa
@team:DataDog/team-aaa
Scenario: Update a role returns "Bad Request" response
Given new "UpdateRole" request
And request contains "role_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {}, "id": "00000000-0000-1111-0000-000000000000", "type": "roles"}}
Given there is a valid "role" in the system
And there is a valid "permission" in the system
And new "UpdateRole" request
And request contains "role_id" parameter from "role.data.id"
And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles", "attributes": {"name" : "{{ role.data.attributes.name }}-updated"}, "relationships": {"permissions": {"data": [{"id": "11111111-dead-beef-dead-ffffffffffff", "type": "{{ permission.type }}"}]}}}}
When the request is sent
Then the response status is 400 Bad Request

@team:DataDog/team-aaa
Scenario: Update a role returns "Bad Role ID" response
Given there is a valid "role" in the system
And there is a valid "permission" in the system
And new "UpdateRole" request
And request contains "role_id" parameter from "role.data.id"
And body with value {"data": {"id": "00000000-dead-beef-dead-ffffffffffff", "type": "roles", "attributes": {"name" : "{{ role.data.attributes.name }}-updated"}}}
And body with value {"data": {"id": "00000000-dead-beef-dead-ffffffffffff", "type": "roles", "attributes": {"name" : "{{ role.data.attributes.name }}-updated"}, "relationships": {"permissions": {"data": [{"type": "{{ permission.type }}", "id": "{{ permission.id }}"}]}}}}
When the request is sent
Then the response status is 422 Bad Role ID in Request

@team:DataDog/team-aaa
Scenario: Update a role returns "Not found" response
Given new "UpdateRole" request
Given there is a valid "permission" in the system
And new "UpdateRole" request
And request contains "role_id" parameter with value "00000000-dead-beef-dead-ffffffffffff"
And body with value {"data": {"id": "00000000-dead-beef-dead-ffffffffffff", "type": "roles", "attributes": {"name" : "updated"}}}
And body with value {"data": {"id": "00000000-dead-beef-dead-ffffffffffff", "type": "roles", "attributes": {"name" : "updated"}, "relationships": {"permissions": {"data": [{"type": "{{ permission.type }}", "id": "{{ permission.id }}"}]}}}}
When the request is sent
Then the response status is 404 Not found

@team:DataDog/team-aaa
Scenario: Update a role returns "OK" response
Given there is a valid "role" in the system
And there is a valid "permission" in the system
And new "UpdateRole" request
And request contains "role_id" parameter from "role.data.id"
And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles", "attributes": {"name" : "{{ role.data.attributes.name }}-updated"}}}
And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles", "attributes": {"name" : "{{ role.data.attributes.name }}-updated"}, "relationships": {"permissions": {"data": [{"id": "{{ permission.id }}", "type": "{{ permission.type }}"}]}}}}
When the request is sent
Then the response status is 200 OK
And the response "data.attributes.name" is equal to "{{ role.data.attributes.name }}-updated"
Expand All @@ -301,6 +306,6 @@ Feature: Roles
Scenario: Update a role returns "Unprocessable Entity" response
Given new "UpdateRole" request
And request contains "role_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {}, "id": "00000000-0000-1111-0000-000000000000", "type": "roles"}}
And body with value {"data": {"attributes": {}, "id": "00000000-0000-1111-0000-000000000000", "relationships": {"permissions": {"data": [{"type": "permissions"}]}, "users": {"data": []}}, "type": "roles"}}
When the request is sent
Then the response status is 422 Unprocessable Entity