Sha256: 97a3e048eaba022af1f02c675e6f6f39afc81a5f8e50166ad0c0e415bde1bc5f

Contents?: true

Size: 1003 Bytes

Versions: 3

Compression:

Stored size: 1003 Bytes

Contents

# Create a service account returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::ServiceAccountsAPI.new

# there is a valid "role" in the system
ROLE_DATA_ID = ENV["ROLE_DATA_ID"]

body = DatadogAPIClient::V2::ServiceAccountCreateRequest.new({
  data: DatadogAPIClient::V2::ServiceAccountCreateData.new({
    type: DatadogAPIClient::V2::UsersType::USERS,
    attributes: DatadogAPIClient::V2::ServiceAccountCreateAttributes.new({
      name: "Test API Client",
      email: "Example-Create_a_service_account_returns_OK_response@datadoghq.com",
      service_account: true,
    }),
    relationships: DatadogAPIClient::V2::UserRelationships.new({
      roles: DatadogAPIClient::V2::RelationshipToRoles.new({
        data: [
          DatadogAPIClient::V2::RelationshipToRoleData.new({
            id: ROLE_DATA_ID,
            type: DatadogAPIClient::V2::RolesType::ROLES,
          }),
        ],
      }),
    }),
  }),
})
p api_instance.create_service_account(body)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datadog_api_client-2.9.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.8.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.7.0 examples/v2/service-accounts/CreateServiceAccount.rb