Sha256: 0f10a7760cc569df5a5663f957cc098ddb8aa311bb79a501ac9e0a4aa058ac03

Contents?: true

Size: 974 Bytes

Versions: 19

Compression:

Stored size: 974 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-Service-Account@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

19 entries across 19 versions & 1 rubygems

Version Path
datadog_api_client-2.28.1 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.27.1 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.26.1 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.26.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.25.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.24.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.22.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.21.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.20.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.19.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.18.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.17.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.16.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.15.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.14.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.13.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.12.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.11.0 examples/v2/service-accounts/CreateServiceAccount.rb
datadog_api_client-2.10.0 examples/v2/service-accounts/CreateServiceAccount.rb