Documentation

Access Resource Policy API

Version: v1

Access Resource Policy API

Version: v1

Access Resource Policy API

This service allows customers and administrators to restrict resources (project and player) read/write access for gaming services.
Download OpenAPI specification:

Get a project based policy


A policy consists of multiple policy statements. This endpoint will return a Policy object containing an array of all non-expired policy statements in that policy.
Authorizations
Use any one of the following options.
ServiceAccount (unity.project_resource_policy.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.project_resource_policy.get
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Get a project based policy"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

HTTP response status codes for "Get a project based policy":

Code samples for "Get a project based policy":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/resource-policy"

Response example

{ "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}

Create or update a project based policy


Create or update a project based policy. A maximum of 500 non-expired statements per policy can be created/updated.
Authorizations
Use any one of the following options.
ServiceAccount (unity.project_resource_policy.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.project_resource_policy.update
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Create or update a project based policy"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

Request body for "Create or update a project based policy"

Media Type:
application/json

statements

array[object]
No description

Sid

string
required
example: statement_id1
Statement ID. Consists of alphanumeric characters and hyphen, and must be of length between 6 and 60 chars.

Action

array[string]
required
User action against which the policy statement will be applicable. Allowable values are "Read", "Write", "*", "Vivox:JoinMuted", "Vivox:JoinAllMuted", "Vivox:JoinWithConsent".

Effect

string
required
Effect of the policy statement. Allowable values are "Allow" and "Deny"

Principal

string
required
The principal the statement applies to, Allowed values are "Player" and "Unauthenticated"

Resource

string
required
example: urn:ugs:cloud-save:*
Uniform resource name of the resource(s) being targeted by the policy. The format is
urn:ugs:<service-name>:/<path>
. For example,
urn:ugs:*
targets all services. Some other examples are
  • urn:ugs:cloud-code:/v1/projects/*/scripts/*
  • urn:ugs:economy:/*

ExpiresAt

string
example: 2020-07-20T18:30:51.243Z
UTC time (ISO 8601 extended format) when the policy expires

Version

string
No description

HTTP response status codes for "Create or update a project based policy":

Code samples for "Create or update a project based policy":

Request example

curl -X PATCH \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/resource-policy"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Delete policy statement(s)


Delete policy statement(s) for project-based policy.
Authorizations
Use any one of the following options.
ServiceAccount (unity.project_resource_policy.delete)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.project_resource_policy.delete
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Delete policy statement(s)"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

Request body for "Delete policy statement(s)"

Media Type:
application/json

statementIDs

array[string]
required
example: ["statementId1","statementId2"]
Array of statement IDs which are to be deleted from the policy

HTTP response status codes for "Delete policy statement(s)":

Code samples for "Delete policy statement(s)":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statementIDs": [ "statementId1", "statementId2" ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/resource-policy:delete-statements"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Get a player based policy


A policy consists of multiple policy statements. This endpoint will return a Policy object containing an array of all non-expired policy statements in that policy.
Authorizations
Use any one of the following options.
ServiceAccount (unity.player_resource_policy.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.get
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Get a player based policy"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

playerId

string
required
example: HgIZuzj0MwDwPO062o0BSVxAcFAV
ID of the player

HTTP response status codes for "Get a player based policy":

Code samples for "Get a player based policy":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/{playerId}/resource-policy"

Response example

{ "playerId": "HgIZuzj0MwDwPO062o0BSVxAcFAV", "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}

Create or update a player based policy


Create or update a player based policy. A maximum of 500 non-expired statements per policy can be created/updated.
Authorizations
Use any one of the following options.
ServiceAccount (unity.player_resource_policy.update)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.update
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Create or update a player based policy"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

playerId

string
required
example: HgIZuzj0MwDwPO062o0BSVxAcFAV
ID of the player

Request body for "Create or update a player based policy"

Media Type:
application/json

statements

array[object]
No description

Sid

string
required
example: statement_id1
Statement ID. Consists of alphanumeric characters and hyphen, and must be of length between 6 and 60 chars.

Action

array[string]
required
User action against which the policy statement will be applicable. Allowable values are "Read", "Write", "*", "Vivox:JoinMuted", "Vivox:JoinAllMuted", "Vivox:JoinWithConsent".

Effect

string
required
Effect of the policy statement. Allowable values are "Allow" and "Deny"

Principal

string
required
The principal the statement applies to, Allowed value is "Player"

Resource

string
required
example: urn:ugs:cloud-save:*
Uniform resource name of the resource(s) being targeted by the policy. The format is
urn:ugs:<service-name>:/<path>
. For example,
urn:ugs:*
targets all services. Some other examples are
  • urn:ugs:cloud-code:/v1/projects/*/scripts/*
  • urn:ugs:economy:/*

ExpiresAt

string
example: 2020-07-20T18:30:51.243Z
UTC time (ISO 8601 extended format) when the policy expires

Version

string
No description

HTTP response status codes for "Create or update a player based policy":

Code samples for "Create or update a player based policy":

Request example

curl -X PATCH \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statements": [ { "Sid": "statement_id1", "Action": [ "string" ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/{playerId}/resource-policy"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Delete policy statement(s)


Delete policy statement(s) for player-based policy.
Authorizations
Use any one of the following options.
ServiceAccount (unity.player_resource_policy.delete)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.delete
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Delete policy statement(s)"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

playerId

string
required
example: HgIZuzj0MwDwPO062o0BSVxAcFAV
ID of the player

Request body for "Delete policy statement(s)"

Media Type:
application/json

statementIDs

array[string]
required
example: ["statementId1","statementId2"]
Array of statement IDs which are to be deleted from the policy

HTTP response status codes for "Delete policy statement(s)":

Code samples for "Delete policy statement(s)":

Request example

curl -X POST \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "statementIDs": [ "statementId1", "statementId2" ]}' \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/{playerId}/resource-policy:delete-statements"

Response example

{ "title": "Bad Request", "status": 400, "detail": "Something is wrong", "details": [ { "code": "ERROR_CODE_123", "path": "nested.value", "message": "Invalid value" } ], "requestId": "aad109f8-033f-4a24-8b77-5032eb3a6158"}

Get all player based policies in project


This endpoint returns all player based policies which belong to a specific project and environment.
By default, the API returns 5 results per page. The number of results per page can be customized by including the limit query parameter in the request. To retrieve subsequent pages of results, pass the next query parameter, the value of which will be provided in the response body of the first paginated response.
Authorizations
Use any one of the following options.
ServiceAccount (unity.player_resource_policy.get)
HTTP: ServiceAccount
To get started with authentication, visit the Service Account Authentication section.
HTTP Authorization Scheme: basic
Required scopes: unity.player_resource_policy.get
or
Bearer
HTTP: Bearer
HTTP Authorization Scheme: bearer

Path parameters for "Get all player based policies in project"

projectId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0b
ID of the project

environmentId

string
required
example: 8bdacc33-6eef-4577-beb0-633c86259f0a
ID of the environment

Query parameters for "Get all player based policies in project"

limit

integer
example: 5
max results per page - is ignored if
next
query parameter is provided

next

string
example: eyJuZXh0IjoiNTliZDIwYjItMWE5My00Y2YxLWJhZWYtYWY3ZTJiNThmZGY2IiwibGltaXQiOjN9
pagination token for requesting next page of results

HTTP response status codes for "Get all player based policies in project":

Code samples for "Get all player based policies in project":

Request example

curl -X GET \ -H "Authorization: Basic <YOUR_CREDENTIALS>" \ -H "Authorization: Bearer <YOUR_TOKEN>" \ "https://services.api.unity.com/access/resource-policy/v1/projects/{projectId}/environments/{environmentId}/players/resource-policy"

Response example

{ "next": "eyJuZXh0IjoiNTliZDIwYjItMWE5My00Y2YxLWJhZWYtYWY3ZTJiNThmZGY2IiwibGltaXQiOjN9", "results": [ { "playerId": "HgIZuzj0MwDwPO062o0BSVxAcFAV", "statements": [ { "Sid": "statement_id1", "Action": [ null ], "Effect": "string", "Principal": "string", "Resource": "urn:ugs:cloud-save:*", "ExpiresAt": "2020-07-20T18:30:51.243Z", "Version": "string" } ] } ]}