Skip to content

Commit afd2d82

Browse files
api-clients-generation-pipeline[bot]jirikuncarci.datadog-api-spec
authored
Mark required type fields in User and Roles API v2 (#75)
* Fix type of type property * Regenerate client from commit 372420b of spec repo Co-authored-by: Jiri Kuncar <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 87731bc commit afd2d82

File tree

9 files changed

+42
-25
lines changed

9 files changed

+42
-25
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.2.0",
7-
"regenerated": "2020-09-17 09:15:42.720492",
8-
"spec_repo_commit": "2cc8a06"
7+
"regenerated": "2020-09-17 14:32:56.640351",
8+
"spec_repo_commit": "372420b"
99
},
1010
"v2": {
1111
"apigentools_version": "1.2.0",
12-
"regenerated": "2020-09-17 09:15:53.976903",
13-
"spec_repo_commit": "2cc8a06"
12+
"regenerated": "2020-09-17 14:33:07.288180",
13+
"spec_repo_commit": "372420b"
1414
}
1515
}
1616
}

docs/v2/RelationshipToOrganizationData.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Relationship to organization object.
44
## Properties
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**id** | **str** | ID of the organization. | [optional]
8-
**type** | [**OrganizationsType**](OrganizationsType.md) | | [optional]
7+
**id** | **str** | ID of the organization. |
8+
**type** | [**OrganizationsType**](OrganizationsType.md) | |
99

1010
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md)
1111

docs/v2/RelationshipToUserData.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Relationship to user object.
44
## Properties
55
Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
7-
**id** | **str** | ID of the user. | [optional]
8-
**type** | **str** | Users type. | [optional] [readonly] if omitted the server will use the default value of "users"
7+
**id** | **str** | ID of the user. |
8+
**type** | [**UsersType**](UsersType.md) | |
99

1010
[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md)
1111

docs/v2/RolesApi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ with datadog_api_client.v2.ApiClient(configuration) as api_client:
186186
body = RelationshipToUser(
187187
data=RelationshipToUserData(
188188
id="id_example",
189-
type="users",
189+
type=UsersType("users"),
190190
),
191191
) # RelationshipToUser | (optional)
192192

@@ -312,7 +312,7 @@ with datadog_api_client.v2.ApiClient(configuration) as api_client:
312312
data=[
313313
RelationshipToUserData(
314314
id="id_example",
315-
type="users",
315+
type=UsersType("users"),
316316
),
317317
],
318318
),
@@ -1097,7 +1097,7 @@ with datadog_api_client.v2.ApiClient(configuration) as api_client:
10971097
body = RelationshipToUser(
10981098
data=RelationshipToUserData(
10991099
id="id_example",
1100-
type="users",
1100+
type=UsersType("users"),
11011101
),
11021102
) # RelationshipToUser | (optional)
11031103

docs/v2/UsersApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ with datadog_api_client.v2.ApiClient(configuration) as api_client:
751751
user=RelationshipToUser(
752752
data=RelationshipToUserData(
753753
id="id_example",
754-
type="users",
754+
type=UsersType("users"),
755755
),
756756
),
757757
),

src/datadog_api_client/v2/model/relationship_to_organization_data.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,13 @@ def discriminator():
102102
])
103103

104104
@convert_js_args_to_python_args
105-
def __init__(self, *args, **kwargs): # noqa: E501
105+
def __init__(self, id, type, *args, **kwargs): # noqa: E501
106106
"""RelationshipToOrganizationData - a model defined in OpenAPI
107107
108+
Args:
109+
id (str): ID of the organization.
110+
type (OrganizationsType):
111+
108112
Keyword Args:
109113
_check_type (bool): if True, values for parameters in openapi_types
110114
will be type checked and a TypeError will be
@@ -136,8 +140,6 @@ def __init__(self, *args, **kwargs): # noqa: E501
136140
Animal class but this time we won't travel
137141
through its discriminator because we passed in
138142
_visited_composed_classes = (Animal,)
139-
id (str): ID of the organization.. [optional] # noqa: E501
140-
type (OrganizationsType): [optional] # noqa: E501
141143
"""
142144

143145
_check_type = kwargs.pop('_check_type', True)
@@ -163,6 +165,8 @@ def __init__(self, *args, **kwargs): # noqa: E501
163165
self._configuration = _configuration
164166
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
165167

168+
self.id = id
169+
self.type = type
166170
for var_name, var_value in kwargs.items():
167171
if var_name not in self.attribute_map and \
168172
self._configuration is not None and \

src/datadog_api_client/v2/model/relationship_to_user_data.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
validate_get_composed_info,
2626
)
2727

28+
def lazy_import():
29+
from datadog_api_client.v2.model.users_type import UsersType
30+
globals()['UsersType'] = UsersType
31+
2832

2933
class RelationshipToUserData(ModelNormal):
3034
"""NOTE: This class is auto generated by OpenAPI Generator.
@@ -70,9 +74,10 @@ def openapi_types():
7074
openapi_types (dict): The key is attribute name
7175
and the value is attribute type.
7276
"""
77+
lazy_import()
7378
return {
7479
'id': (str,), # noqa: E501
75-
'type': (str,), # noqa: E501
80+
'type': (UsersType,), # noqa: E501
7681
}
7782

7883
@cached_property
@@ -97,9 +102,13 @@ def discriminator():
97102
])
98103

99104
@convert_js_args_to_python_args
100-
def __init__(self, *args, **kwargs): # noqa: E501
105+
def __init__(self, id, type, *args, **kwargs): # noqa: E501
101106
"""RelationshipToUserData - a model defined in OpenAPI
102107
108+
Args:
109+
id (str): ID of the user.
110+
type (UsersType):
111+
103112
Keyword Args:
104113
_check_type (bool): if True, values for parameters in openapi_types
105114
will be type checked and a TypeError will be
@@ -131,8 +140,6 @@ def __init__(self, *args, **kwargs): # noqa: E501
131140
Animal class but this time we won't travel
132141
through its discriminator because we passed in
133142
_visited_composed_classes = (Animal,)
134-
id (str): ID of the user.. [optional] # noqa: E501
135-
type (str): Users type.. [optional] if omitted the server will use the default value of "users" # noqa: E501
136143
"""
137144

138145
_check_type = kwargs.pop('_check_type', True)
@@ -158,6 +165,8 @@ def __init__(self, *args, **kwargs): # noqa: E501
158165
self._configuration = _configuration
159166
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
160167

168+
self.id = id
169+
self.type = type
161170
for var_name, var_value in kwargs.items():
162171
if var_name not in self.attribute_map and \
163172
self._configuration is not None and \

src/datadog_api_client/v2/openapi.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,9 @@ components:
11931193
type: string
11941194
type:
11951195
$ref: '#/components/schemas/OrganizationsType'
1196+
required:
1197+
- id
1198+
- type
11961199
type: object
11971200
RelationshipToOrganizations:
11981201
description: Relationship to organizations.
@@ -1265,10 +1268,10 @@ components:
12651268
description: ID of the user.
12661269
type: string
12671270
type:
1268-
default: users
1269-
description: Users type.
1270-
readOnly: true
1271-
type: string
1271+
$ref: '#/components/schemas/UsersType'
1272+
required:
1273+
- id
1274+
- type
12721275
type: object
12731276
RelationshipToUsers:
12741277
description: Relationship to users.
@@ -2224,6 +2227,7 @@ components:
22242227
description: Users resource type.
22252228
enum:
22262229
- users
2230+
example: users
22272231
type: string
22282232
x-enum-varnames:
22292233
- USERS

tests/v2/test_scenarios.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def user_has_role(vcr_cassette, client, user, role):
104104
body = relationship_to_user.RelationshipToUser(
105105
data=relationship_to_user_data.RelationshipToUserData(
106106
id=user.data.id,
107-
type=str(user.data.type),
107+
type=user.data.type,
108108
))
109109
yield api.add_user_to_role(role.data.id, body=body)
110110
if vcr_cassette.record_mode != "none":
@@ -137,7 +137,7 @@ def user_invitation(vcr_cassette, client, user):
137137
user=relationship_to_user.RelationshipToUser(
138138
data=relationship_to_user_data.RelationshipToUserData(
139139
id=user.data.id,
140-
type=str(user.data.type),
140+
type=user.data.type,
141141
))))
142142
], )
143143
yield api.send_invitations(body=body).data[0]

0 commit comments

Comments
 (0)