From a2e6a0f7c486ba9ef8e8275b125a320003fbef12 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 1 Feb 2023 18:26:52 +0000 Subject: [PATCH] Regenerate client from commit a7d9eeca of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 2 +- api/datadogV2/api_service_accounts.go | 100 ++++++++++++++++++ api/datadogV2/api_users.go | 100 ------------------ api/datadogV2/doc.go | 2 +- .../CreateServiceAccount.go | 6 +- tests/scenarios/api_mappings.go | 2 +- ...service_account_returns_OK_response.freeze | 1 + ...a_service_account_returns_OK_response.yaml | 87 +++++++++++++++ ...service_account_returns_OK_response.freeze | 1 - ...a_service_account_returns_OK_response.yaml | 78 -------------- tests/scenarios/features/v2/given.json | 2 +- .../features/v2/service_accounts.feature | 20 ++++ tests/scenarios/features/v2/undo.json | 3 +- tests/scenarios/features/v2/users.feature | 20 ---- 15 files changed, 221 insertions(+), 211 deletions(-) rename examples/v2/{users => service-accounts}/CreateServiceAccount.go (83%) create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.yaml delete mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.freeze delete mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index b4ff6cdf2df..e1cb3fc3b40 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-02-01 12:21:07.288764", - "spec_repo_commit": "0563dbc3" + "regenerated": "2023-02-01 18:25:28.917567", + "spec_repo_commit": "a7d9eeca" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-02-01 12:21:07.303722", - "spec_repo_commit": "0563dbc3" + "regenerated": "2023-02-01 18:25:28.929658", + "spec_repo_commit": "a7d9eeca" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a1942e2eccc..6aedb5ad948 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -19082,7 +19082,7 @@ paths: $ref: '#/components/responses/TooManyRequestsResponse' summary: Create a service account tags: - - Users + - Service Accounts x-codegen-request-body-name: body /api/v2/service_accounts/{service_account_id}/application_keys: get: diff --git a/api/datadogV2/api_service_accounts.go b/api/datadogV2/api_service_accounts.go index b05d10024e0..d30ab742bb6 100644 --- a/api/datadogV2/api_service_accounts.go +++ b/api/datadogV2/api_service_accounts.go @@ -16,6 +16,106 @@ import ( // ServiceAccountsApi service type type ServiceAccountsApi datadog.Service +type apiCreateServiceAccountRequest struct { + ctx _context.Context + body *ServiceAccountCreateRequest +} + +func (a *ServiceAccountsApi) buildCreateServiceAccountRequest(ctx _context.Context, body ServiceAccountCreateRequest) (apiCreateServiceAccountRequest, error) { + req := apiCreateServiceAccountRequest{ + ctx: ctx, + body: &body, + } + return req, nil +} + +// CreateServiceAccount Create a service account. +// Create a service account for your organization. +func (a *ServiceAccountsApi) CreateServiceAccount(ctx _context.Context, body ServiceAccountCreateRequest) (UserResponse, *_nethttp.Response, error) { + req, err := a.buildCreateServiceAccountRequest(ctx, body) + if err != nil { + var localVarReturnValue UserResponse + return localVarReturnValue, nil, err + } + + return a.createServiceAccountExecute(req) +} + +// createServiceAccountExecute executes the request. +func (a *ServiceAccountsApi) createServiceAccountExecute(r apiCreateServiceAccountRequest) (UserResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue UserResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.ServiceAccountsApi.CreateServiceAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/service_accounts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type apiCreateServiceAccountApplicationKeyRequest struct { ctx _context.Context serviceAccountId string diff --git a/api/datadogV2/api_users.go b/api/datadogV2/api_users.go index 37a4439e111..aa449393cfb 100644 --- a/api/datadogV2/api_users.go +++ b/api/datadogV2/api_users.go @@ -16,106 +16,6 @@ import ( // UsersApi service type type UsersApi datadog.Service -type apiCreateServiceAccountRequest struct { - ctx _context.Context - body *ServiceAccountCreateRequest -} - -func (a *UsersApi) buildCreateServiceAccountRequest(ctx _context.Context, body ServiceAccountCreateRequest) (apiCreateServiceAccountRequest, error) { - req := apiCreateServiceAccountRequest{ - ctx: ctx, - body: &body, - } - return req, nil -} - -// CreateServiceAccount Create a service account. -// Create a service account for your organization. -func (a *UsersApi) CreateServiceAccount(ctx _context.Context, body ServiceAccountCreateRequest) (UserResponse, *_nethttp.Response, error) { - req, err := a.buildCreateServiceAccountRequest(ctx, body) - if err != nil { - var localVarReturnValue UserResponse - return localVarReturnValue, nil, err - } - - return a.createServiceAccountExecute(req) -} - -// createServiceAccountExecute executes the request. -func (a *UsersApi) createServiceAccountExecute(r apiCreateServiceAccountRequest) (UserResponse, *_nethttp.Response, error) { - var ( - localVarHTTPMethod = _nethttp.MethodPost - localVarPostBody interface{} - localVarReturnValue UserResponse - ) - - localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.UsersApi.CreateServiceAccount") - if err != nil { - return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} - } - - localVarPath := localBasePath + "/api/v2/service_accounts" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := _neturl.Values{} - localVarFormParams := _neturl.Values{} - if r.body == nil { - return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") - } - localVarHeaderParams["Content-Type"] = "application/json" - localVarHeaderParams["Accept"] = "application/json" - - // body params - localVarPostBody = r.body - datadog.SetAuthKeys( - r.ctx, - &localVarHeaderParams, - [2]string{"apiKeyAuth", "DD-API-KEY"}, - [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, - ) - req, err := a.Client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.Client.CallAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := datadog.ReadBody(localVarHTTPResponse) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := datadog.GenericOpenAPIError{ - ErrorBody: localVarBody, - ErrorMessage: localVarHTTPResponse.Status, - } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { - var v APIErrorResponse - err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.ErrorModel = v - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := datadog.GenericOpenAPIError{ - ErrorBody: localVarBody, - ErrorMessage: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - type apiCreateUserRequest struct { ctx _context.Context body *UserCreateRequest diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c121d72a2b4..bbd1bc797c3 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -176,6 +176,7 @@ // - [SensitiveDataScannerApi.ReorderScanningGroups] // - [SensitiveDataScannerApi.UpdateScanningGroup] // - [SensitiveDataScannerApi.UpdateScanningRule] +// - [ServiceAccountsApi.CreateServiceAccount] // - [ServiceAccountsApi.CreateServiceAccountApplicationKey] // - [ServiceAccountsApi.DeleteServiceAccountApplicationKey] // - [ServiceAccountsApi.GetServiceAccountApplicationKey] @@ -192,7 +193,6 @@ // - [UsageMeteringApi.GetUsageApplicationSecurityMonitoring] // - [UsageMeteringApi.GetUsageLambdaTracedInvocations] // - [UsageMeteringApi.GetUsageObservabilityPipelines] -// - [UsersApi.CreateServiceAccount] // - [UsersApi.CreateUser] // - [UsersApi.DisableUser] // - [UsersApi.GetInvitation] diff --git a/examples/v2/users/CreateServiceAccount.go b/examples/v2/service-accounts/CreateServiceAccount.go similarity index 83% rename from examples/v2/users/CreateServiceAccount.go rename to examples/v2/service-accounts/CreateServiceAccount.go index 29d4e1cbe9a..6d08aad1ca2 100644 --- a/examples/v2/users/CreateServiceAccount.go +++ b/examples/v2/service-accounts/CreateServiceAccount.go @@ -39,14 +39,14 @@ func main() { ctx := datadog.NewDefaultContext(context.Background()) configuration := datadog.NewConfiguration() apiClient := datadog.NewAPIClient(configuration) - api := datadogV2.NewUsersApi(apiClient) + api := datadogV2.NewServiceAccountsApi(apiClient) resp, r, err := api.CreateServiceAccount(ctx, body) if err != nil { - fmt.Fprintf(os.Stderr, "Error when calling `UsersApi.CreateServiceAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Error when calling `ServiceAccountsApi.CreateServiceAccount`: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) } responseContent, _ := json.MarshalIndent(resp, "", " ") - fmt.Fprintf(os.Stdout, "Response from `UsersApi.CreateServiceAccount`:\n%s\n", responseContent) + fmt.Fprintf(os.Stdout, "Response from `ServiceAccountsApi.CreateServiceAccount`:\n%s\n", responseContent) } diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 70841b56a4d..516ac8c889a 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -68,11 +68,11 @@ var apiMappings = map[string]map[string]reflect.Value{ "CloudWorkloadSecurityApi": reflect.ValueOf(datadogV2.NewCloudWorkloadSecurityApi), "SecurityMonitoringApi": reflect.ValueOf(datadogV2.NewSecurityMonitoringApi), "SensitiveDataScannerApi": reflect.ValueOf(datadogV2.NewSensitiveDataScannerApi), - "UsersApi": reflect.ValueOf(datadogV2.NewUsersApi), "ServiceAccountsApi": reflect.ValueOf(datadogV2.NewServiceAccountsApi), "IncidentServicesApi": reflect.ValueOf(datadogV2.NewIncidentServicesApi), "ServiceDefinitionApi": reflect.ValueOf(datadogV2.NewServiceDefinitionApi), "IncidentTeamsApi": reflect.ValueOf(datadogV2.NewIncidentTeamsApi), "UsageMeteringApi": reflect.ValueOf(datadogV2.NewUsageMeteringApi), + "UsersApi": reflect.ValueOf(datadogV2.NewUsersApi), }, } \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.freeze new file mode 100644 index 00000000000..7536a9c5b3e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-01-30T14:58:54.329Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.yaml new file mode 100644 index 00000000000..ebcfa4ef33c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_a_service_account_returns_OK_response.yaml @@ -0,0 +1,87 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"name":"Test-Create_a_service_account_returns_OK_response-1675090734"},"type":"roles"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/roles + response: + body: '{"data":{"type":"roles","id":"9d7c873e-a0ae-11ed-975e-da7ad0900002","attributes":{"name":"Test-Create_a_service_account_returns_OK_response-1675090734","created_at":"2023-01-30T14:58:54.528421+00:00","modified_at":"2023-01-30T14:58:54.566829+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"},{"type":"permissions","id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002"},{"type":"permissions","id":"f8e941cf-e746-11ec-b22d-da7ad0900002"},{"type":"permissions","id":"6c5ad874-7aff-11ed-a5cd-da7ad0900002"}]}}}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"email":"Test-Create_a_service_account_returns_OK_response-1675090734@datadoghq.com","name":"Test API Client","service_account":true},"relationships":{"roles":{"data":[{"id":"9d7c873e-a0ae-11ed-975e-da7ad0900002","type":"roles"}]}},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts + response: + body: '{"data":{"type":"users","id":"9d9c0565-a0ae-11ed-88af-be56a8628f3f","attributes":{"name":"Test + API Client","handle":"9d9c0565-a0ae-11ed-88af-be56a8628f3f","created_at":"2023-01-30T14:58:54.736093+00:00","modified_at":"2023-01-30T14:58:54.738680+00:00","email":"test-create_a_service_account_returns_ok_response-1675090734@datadoghq.com","icon":"https://secure.gravatar.com/avatar/5bf68b66c63c55ddb80602fc2d183c28?s=48&d=retro","title":null,"verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active"},"relationships":{"roles":{"data":[{"type":"roles","id":"9d7c873e-a0ae-11ed-975e-da7ad0900002"}]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}},"included":[{"type":"roles","id":"9d7c873e-a0ae-11ed-975e-da7ad0900002","attributes":{"name":"Test-Create_a_service_account_returns_OK_response-1675090734","created_at":"2023-01-30T14:58:54.528421+00:00","modified_at":"2023-01-30T14:58:54.566829+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"},{"type":"permissions","id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002"},{"type":"permissions","id":"f8e941cf-e746-11ec-b22d-da7ad0900002"},{"type":"permissions","id":"6c5ad874-7aff-11ed-a5cd-da7ad0900002"}]}}},{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2","attributes":{"name":"dashboards_read","display_name":"Dashboards + Read","description":"View dashboards.","created":"2019-09-10T14:39:51.955175+00:00","group_name":"Dashboards","display_type":"read","restricted":true}},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304","attributes":{"name":"monitors_read","display_name":"Monitors + Read","description":"View monitors.","created":"2019-09-16T18:39:07.744297+00:00","group_name":"Monitors","display_type":"read","restricted":true}},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0","attributes":{"name":"apm_read","display_name":"APM + Read","description":"Read and query APM and Trace Analytics.","created":"2020-11-23T20:55:45.006110+00:00","group_name":"APM","display_type":"read","restricted":true}},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002","attributes":{"name":"incident_read","display_name":"Incident + Read","description":"View incidents in Datadog.","created":"2021-06-22T15:11:09.255499+00:00","group_name":"Case + and Incident Management","display_type":"read","restricted":true}},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002","attributes":{"name":"rum_apps_read","display_name":"RUM + Apps Read","description":"View RUM Applications data.","created":"2021-08-02T09:46:07.671535+00:00","group_name":"Real + User Monitoring","display_type":"read","restricted":true}},{"type":"permissions","id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002","attributes":{"name":"notebooks_read","display_name":"Notebooks + Read","description":"View notebooks.","created":"2022-03-02T18:51:05.040950+00:00","group_name":"Notebooks","display_type":"read","restricted":true}},{"type":"permissions","id":"f8e941cf-e746-11ec-b22d-da7ad0900002","attributes":{"name":"slos_read","display_name":"SLOs + Read","description":"View SLOs and status corrections.","created":"2022-06-08T16:20:55.142591+00:00","group_name":"Service + Level Objectives","display_type":"read","restricted":true}},{"type":"permissions","id":"6c5ad874-7aff-11ed-a5cd-da7ad0900002","attributes":{"name":"ci_visibility_read","display_name":"CI + Visibility Read","description":"View CI Visibility.","created":"2022-12-13T16:01:37.149406+00:00","group_name":"CI + Visibility","display_type":"read","restricted":true}}]} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/users/9d9c0565-a0ae-11ed-88af-be56a8628f3f + response: + body: '' + code: 204 + duration: '' + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/roles/9d7c873e-a0ae-11ed-975e-da7ad0900002 + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.freeze deleted file mode 100644 index 7dd3712dc6b..00000000000 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.freeze +++ /dev/null @@ -1 +0,0 @@ -2022-05-12T09:53:33.281Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.yaml deleted file mode 100644 index 8848ab9eca5..00000000000 --- a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Users/Scenario_Create_a_service_account_returns_OK_response.yaml +++ /dev/null @@ -1,78 +0,0 @@ -interactions: -- request: - body: | - {"data":{"attributes":{"name":"Test-Create_a_service_account_returns_OK_response-1652349213"},"type":"roles"}} - form: {} - headers: - Accept: - - application/json - Content-Type: - - application/json - method: POST - url: https://api.datadoghq.com/api/v2/roles - response: - body: '{"data":{"type":"roles","id":"62caae30-d1d9-11ec-ad3d-da7ad0900002","attributes":{"name":"Test-Create_a_service_account_returns_OK_response-1652349213","created_at":"2022-05-12T09:53:33.719840+00:00","modified_at":"2022-05-12T09:53:33.777510+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"},{"type":"permissions","id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002"}]}}}}' - code: 200 - duration: '' - headers: - Content-Type: - - application/json - status: 200 OK -- request: - body: | - {"data":{"attributes":{"email":"Test-Create_a_service_account_returns_OK_response-1652349213@datadoghq.com","name":"Test API Client","service_account":true},"relationships":{"roles":{"data":[{"id":"62caae30-d1d9-11ec-ad3d-da7ad0900002","type":"roles"}]}},"type":"users"}} - form: {} - headers: - Accept: - - application/json - Content-Type: - - application/json - method: POST - url: https://api.datadoghq.com/api/v2/service_accounts - response: - body: '{"included":[{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002","attributes":{"name":"rum_apps_read","display_name":"RUM - Apps Read","description":"View RUM Applications data.","created":"2021-08-02T09:46:07.671535+00:00","group_name":"Real - User Monitoring","display_type":"read","restricted":true}},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002","attributes":{"name":"incident_read","display_name":"Incident - Read","description":"View incidents in Datadog.","created":"2021-06-22T15:11:09.255499+00:00","group_name":"Incidents","display_type":"read","restricted":true}},{"type":"roles","id":"62caae30-d1d9-11ec-ad3d-da7ad0900002","attributes":{"name":"Test-Create_a_service_account_returns_OK_response-1652349213","created_at":"2022-05-12T09:53:33.719840+00:00","modified_at":"2022-05-12T09:53:33.777510+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"},{"type":"permissions","id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002"}]}}},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002","attributes":{"name":"appsec_event_rule_read","display_name":"Application - Security Event Rules Read","description":"View Application Security Event Rules.","created":"2021-07-19T13:31:15.595771+00:00","group_name":"Cloud - Security Platform","display_type":"read","restricted":true}},{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2","attributes":{"name":"dashboards_read","display_name":"Dashboards - Read","description":"View dashboards.","created":"2019-09-10T14:39:51.955175+00:00","group_name":"Dashboards","display_type":"read","restricted":true}},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0","attributes":{"name":"apm_read","display_name":"APM - Read","description":"Read and query APM and Trace Analytics.","created":"2020-11-23T20:55:45.006110+00:00","group_name":"APM","display_type":"read","restricted":true}},{"type":"permissions","id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002","attributes":{"name":"notebooks_read","display_name":"Notebooks - Read","description":"View notebooks.","created":"2022-03-02T18:51:05.040950+00:00","group_name":"Notebooks","display_type":"read","restricted":true}},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304","attributes":{"name":"monitors_read","display_name":"Monitors - Read","description":"View monitors.","created":"2019-09-16T18:39:07.744297+00:00","group_name":"Monitors","display_type":"read","restricted":true}}],"data":{"type":"users","id":"1ee25455-00f0-41f0-bd0f-2844f17acbf0","attributes":{"name":"Test - API Client","handle":"1ee25455-00f0-41f0-bd0f-2844f17acbf0","created_at":"2022-05-12T09:53:34.261663+00:00","modified_at":"2022-05-12T09:53:34.298254+00:00","email":"test-create_a_service_account_returns_ok_response-1652349213@datadoghq.com","icon":"https://secure.gravatar.com/avatar/2b603941f3590a948fbfeb4debfce25f?s=48&d=retro","title":null,"verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active"},"relationships":{"roles":{"data":[{"type":"roles","id":"62caae30-d1d9-11ec-ad3d-da7ad0900002"}]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}}' - code: 201 - duration: '' - headers: - Content-Type: - - application/json - status: 201 Created -- request: - body: '' - form: {} - headers: - Accept: - - '*/*' - method: DELETE - url: https://api.datadoghq.com/api/v2/users/1ee25455-00f0-41f0-bd0f-2844f17acbf0 - response: - body: '' - code: 204 - duration: '' - headers: {} - status: 204 No Content -- request: - body: '' - form: {} - headers: - Accept: - - '*/*' - method: DELETE - url: https://api.datadoghq.com/api/v2/roles/62caae30-d1d9-11ec-ad3d-da7ad0900002 - response: - body: '' - code: 204 - duration: '' - headers: {} - status: 204 No Content -version: 1 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 68ded41e15d..1ae176c20a9 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -357,7 +357,7 @@ ], "step": "there is a valid \"service_account_user\" in the system", "key": "service_account_user", - "tag": "Users", + "tag": "Service Accounts", "operationId": "CreateServiceAccount" }, { diff --git a/tests/scenarios/features/v2/service_accounts.feature b/tests/scenarios/features/v2/service_accounts.feature index 6428b5b9748..de4f1249410 100644 --- a/tests/scenarios/features/v2/service_accounts.feature +++ b/tests/scenarios/features/v2/service_accounts.feature @@ -7,6 +7,26 @@ Feature: Service Accounts And a valid "appKeyAuth" key in the system And an instance of "ServiceAccounts" API + @generated @skip @team:DataDog/team-aaa + Scenario: Create a service account returns "Bad Request" response + Given new "CreateServiceAccount" request + And body with value {"data": {"attributes": {"email": "jane.doe@example.com", "service_account": true}, "relationships": {"roles": {"data": [{"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}]}}, "type": "users"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa + Scenario: Create a service account returns "OK" response + Given there is a valid "role" in the system + And new "CreateServiceAccount" request + And body with value {"data": {"type": "users", "attributes": {"name": "Test API Client", "email": "{{ unique }}@datadoghq.com", "service_account": true}, "relationships": {"roles": {"data": [{"id": "{{ role.data.id }}", "type": "roles"}]}}}} + When the request is sent + Then the response status is 201 OK + And the response "data.attributes.email" is equal to "{{ unique_lower }}@datadoghq.com" + And the response "data.attributes.name" is equal to "Test API Client" + And the response "data.attributes.disabled" is false + And the response "data.attributes.service_account" is equal to true + And the response "data.relationships.roles.data[0].id" is equal to "{{ role.data.id }}" + @team:DataDog/team-aaa Scenario: Create an app key for this service account returns "Created" response Given there is a valid "service_account_user" in the system diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index cc8b7cd1839..58685b554d2 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1140,7 +1140,7 @@ } }, "CreateServiceAccount": { - "tag": "Users", + "tag": "Service Accounts", "undo": { "operationId": "DisableUser", "parameters": [ @@ -1149,6 +1149,7 @@ "source": "data.id" } ], + "tag": "Users", "type": "unsafe" } }, diff --git a/tests/scenarios/features/v2/users.feature b/tests/scenarios/features/v2/users.feature index 0c9b908a84c..0510d56cc7e 100644 --- a/tests/scenarios/features/v2/users.feature +++ b/tests/scenarios/features/v2/users.feature @@ -7,26 +7,6 @@ Feature: Users And a valid "appKeyAuth" key in the system And an instance of "Users" API - @generated @skip @team:DataDog/team-aaa - Scenario: Create a service account returns "Bad Request" response - Given new "CreateServiceAccount" request - And body with value {"data": {"attributes": {"email": "jane.doe@example.com", "service_account": true}, "relationships": {"roles": {"data": [{"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}]}}, "type": "users"}} - When the request is sent - Then the response status is 400 Bad Request - - @team:DataDog/team-aaa - Scenario: Create a service account returns "OK" response - Given there is a valid "role" in the system - And new "CreateServiceAccount" request - And body with value {"data": {"type": "users", "attributes": {"name": "Test API Client", "email": "{{ unique }}@datadoghq.com", "service_account": true}, "relationships": {"roles": {"data": [{"id": "{{ role.data.id }}", "type": "roles"}]}}}} - When the request is sent - Then the response status is 201 OK - And the response "data.attributes.email" is equal to "{{ unique_lower }}@datadoghq.com" - And the response "data.attributes.name" is equal to "Test API Client" - And the response "data.attributes.disabled" is false - And the response "data.attributes.service_account" is equal to true - And the response "data.relationships.roles.data[0].id" is equal to "{{ role.data.id }}" - @generated @skip @team:DataDog/team-aaa Scenario: Create a user returns "Bad Request" response Given new "CreateUser" request