Skip to content

Commit dfb657f

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Mark access_role as nullable (#1226)
* fix example generator * Regenerate client from commit 7ca677d6 of spec repo --------- Co-authored-by: Sherzod Karimov <[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 c30d515 commit dfb657f

File tree

13 files changed

+279
-19
lines changed

13 files changed

+279
-19
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.6.5",
7-
"regenerated": "2023-07-10 17:45:27.823253",
8-
"spec_repo_commit": "9e0b471a"
7+
"regenerated": "2023-07-11 14:36:39.086601",
8+
"spec_repo_commit": "7ca677d6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-07-10 17:45:27.841604",
13-
"spec_repo_commit": "9e0b471a"
12+
"regenerated": "2023-07-11 14:36:39.100169",
13+
"spec_repo_commit": "7ca677d6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,15 @@ components:
352352
type: array
353353
type: object
354354
AccessRole:
355-
default: st
356355
description: The access role of the user. Options are **st** (standard user),
357356
**adm** (admin user), or **ro** (read-only user).
358357
enum:
359358
- st
360359
- adm
361360
- ro
362361
- ERROR
363-
example: st
362+
example: ro
363+
nullable: true
364364
type: string
365365
x-enum-varnames:
366366
- STANDARD

.generator/src/generator/formatter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,11 @@ def format_data_with_schema(
231231

232232
nullable = schema.get("nullable", False)
233233

234-
if "enum" in schema and data not in schema["enum"]:
235-
raise ValueError(f"{data} is not valid enum value {schema['enum']}")
234+
if "enum" in schema:
235+
if nullable and data is None:
236+
pass
237+
elif data not in schema["enum"]:
238+
raise ValueError(f"{data} is not valid enum value {schema['enum']}")
236239

237240
if replace_values and data in replace_values:
238241
# TODO convert replaced value if it is not string and it is used in given
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-07-10T18:57:28.744Z"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Users/Create a user returns \"User created\" response test",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "c6a3807891b69d0016b7a45bf564a768",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 115,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 549,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"access_role\":\"st\",\"disabled\":false,\"email\":\"[email protected]\",\"handle\":\"[email protected]\",\"name\":\"test user\"}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/user"
39+
},
40+
"response": {
41+
"bodySize": 274,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 274,
45+
"text": "{\"user\":{\"handle\":\"[email protected]\",\"name\":\"test user\",\"role\":null,\"title\":null,\"email\":\"[email protected]\",\"disabled\":false,\"access_role\":null,\"is_admin\":false,\"icon\":\"https://secure.gravatar.com/avatar/f979f58720feb88e09cc3d11ce3d15da?s=48&d=retro\",\"verified\":false}}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 650,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2023-07-10T18:57:28.752Z",
61+
"time": 506
62+
},
63+
{
64+
"_id": "af6170722860ba27e045b00c8baf0187",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 520,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/user/test%40datadoghq.com"
82+
},
83+
"response": {
84+
"bodySize": 47,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 47,
88+
"text": "{\"message\":\"User [email protected] disabled\"}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 516,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2023-07-10T18:57:29.271Z",
104+
"time": 208
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-07-10T18:58:47.628Z"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Users/Create a user returns null access role",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "caca59e8b77c5fba34ff14276808609d",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 115,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 549,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"access_role\":null,\"disabled\":false,\"email\":\"[email protected]\",\"handle\":\"[email protected]\",\"name\":\"test user\"}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/user"
39+
},
40+
"response": {
41+
"bodySize": 273,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 273,
45+
"text": "{\"user\":{\"handle\":\"[email protected]\",\"name\":\"test user\",\"role\":null,\"title\":null,\"email\":\"[email protected]\",\"disabled\":true,\"access_role\":null,\"is_admin\":false,\"icon\":\"https://secure.gravatar.com/avatar/f979f58720feb88e09cc3d11ce3d15da?s=48&d=retro\",\"verified\":false}}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 650,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2023-07-10T18:58:47.635Z",
61+
"time": 624
62+
},
63+
{
64+
"_id": "af6170722860ba27e045b00c8baf0187",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 520,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/user/test%40datadoghq.com"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"errors\":[\"User is already disabled\"]}"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 516,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 400,
101+
"statusText": "Bad Request"
102+
},
103+
"startedDateTime": "2023-07-10T18:58:48.272Z",
104+
"time": 140
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}

examples/v1/organizations/UpdateOrg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const params: v1.OrganizationsApiUpdateOrgRequest = {
2020
saml: {
2121
enabled: false,
2222
},
23-
samlAutocreateAccessRole: "st",
23+
samlAutocreateAccessRole: "ro",
2424
samlAutocreateUsersDomains: {
2525
domains: ["example.com"],
2626
enabled: false,

examples/v1/users/CreateUser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const apiInstance = new v1.UsersApi(configuration);
99

1010
const params: v1.UsersApiCreateUserRequest = {
1111
body: {
12-
accessRole: "st",
12+
accessRole: "ro",
1313
disabled: false,
1414
1515
handle: "[email protected]",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Create a user returns null access role
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.UsersApi(configuration);
9+
10+
const params: v1.UsersApiCreateUserRequest = {
11+
body: {
12+
accessRole: undefined,
13+
disabled: false,
14+
15+
handle: "[email protected]",
16+
name: "test user",
17+
},
18+
};
19+
20+
apiInstance
21+
.createUser(params)
22+
.then((data: v1.UserResponse) => {
23+
console.log(
24+
"API called successfully. Returned data: " + JSON.stringify(data)
25+
);
26+
})
27+
.catch((error: any) => console.error(error));

0 commit comments

Comments
 (0)