Introduction
With the IBM Cloud® Identity and Access Management (IAM) Policy Management API, you can create, update, view, and delete IAM policies. An IAM policy enables a subject to access a resource. These policies are used in access decisions when you call APIs for IAM-enabled services. For more information about how access management works, see Managing access in IBM Cloud.
There are three primary values in a policy: a subject, roles, and resources.
The subject is who or what is being granted access. The subject can be an IAM ID or an access group ID. The IAM ID is the ID of the entity that you are giving access to. The value can be a user or a service ID. The access group ID is the ID of the access group. An access group contains a set of users or service IDs. Access groups are the preferred method of managing access control. For more information, see Setting up access groups.
The following table shows the example formats for the supported subject types:
| Type | Attribute name | Attribute value |
|---|---|---|
| User | iam_id | IBMid-123456... |
| Service ID | iam_id | iam-ServiceId-12345... |
| Access group | access_group_id | AccessGroupId-12345... |
The second value in a policy in the role. A role is a collection of actions that can be taken on a resource. There are platform, service, and custom roles. For more information, see IAM roles. And, the final value of the policy is the targeted resources whether it's an entire service, resource group, or specific service instance.
Two types of policies are supported: access policies and authorization policies. For more information, see Create a policy.
With policy templates and assignments you can centrally manage the policies for child accounts in your organization from the root enterprise account. For more information, see Working with template versions and Best practices for assigning access in an enterprise.
SDKs for Java, Node, Python, and Go are available to make it easier to programmatically access the API from your code. The client libraries that are provided by the SDKs implement best practices for using the API and reduce the amount of code that you need to write. The tab for each language includes code examples that demonstrate how to use the client libraries. For more information about using the SDKs, see the IBM Cloud SDK Common project on GitHub.
Installing the Go SDK
Go modules (recommended): Add the following import in your code, and then run go build or go mod tidy
import (
"github.com/IBM/platform-services-go-sdk/iampolicymanagementv1"
)
Go get
go get -u github.com/IBM/platform-services-go-sdk/iampolicymanagementv1
View on GitHub
Installing the Java SDK
Maven
<dependency>
<groupId>com.ibm.cloud</groupId>
<artifactId>iam-policy-management</artifactId>
<version>{version}</version>
</dependency>
Gradle
compile 'com.ibm.cloud:iam-policy-management:{version}'
Replace {version} in these examples with the release version.
View on GitHub
Installing the Node SDK
npm install ibm-platform-services
View on GitHub
Installing the Python SDK
pip install --upgrade "ibm-platform-services"
View on GitHub
Endpoint URLs
The IAM Policy Management API uses the following public global endpoint URL. When you call the API, add the path for each method to form the complete API endpoint for your requests.
https://iam.cloud.ibm.com
If you enabled service endpoints in your account, you can send API requests over the IBM Cloud private network at the following base endpoint URLs. For more information, see Enabling VRF and service endpoints.
- Private endpoint URL for VPC infrastructure:
https://private.iam.cloud.ibm.com - Private endpoint URLs for classic infrastructure:
- Sydney:
https://private.au-syd.iam.cloud.ibm.com - Sao Paulo:
https://private.br-sao.iam.cloud.ibm.com - Montreal:
https://private.ca-mon.iam.cloud.ibm.com - Toronto:
https://private.ca-tor.iam.cloud.ibm.com - Frankfurt DC:
https://private.eu-de.iam.cloud.ibm.com - London:
https://private.eu-gb.iam.cloud.ibm.com - Madrid:
https://private.eu-es.iam.cloud.ibm.com - Tokyo:
https://private.jp-tok.iam.cloud.ibm.com - Osaka:
https://private.jp-osa.iam.cloud.ibm.com - Washington DC:
https://private.us-east.iam.cloud.ibm.com - Dallas:
https://private.us-south.iam.cloud.ibm.com
- Sydney:
Authentication
Authorization to the IAM Policy Management API is enforced by using an IBM Cloud IAM access token. The token is used to to determine the actions that a user or service ID has access to when they use the API.
Obtaining an IAM token for an authenticated user or service ID is described in the IAM Identity Services API documentation.
To use the API, add a valid IAM token to the HTTP Authorization request header, for example, -H 'Authorization: Bearer <TOKEN>'.
When you use the SDK, configure an IAM authenticator with the IAM API key. The authenticator automatically obtains the IAM access token for the API key and includes it with each request. You can construct an authenticator in either of two ways:
- Programmatically by constructing an IAM authenticator instance and supplying your IAM API key
- By defining the API key in external configuration properties and then using the SDK authenticator factory to construct an IAM authenticator that uses the configured IAM API key
In this example of using external configuration properties, an IAM authenticator instance is created with the configured API key, and then the service client is constructed with this authenticator instance and the configured service URL.
For more information, see the Authentication section of the IBM Cloud SDK Common documentation.
Any access, such as IAM actions, that is required to call a method is listed per individual method. The IAM actions associated with basic tasks for working with policies, including create, update, and delete actions, are inherited by the platform roles that can be assigned for each IAM-enabled service. For more information about the required IAM actions for custom roles and how they map to the access roles, see the list of actions and roles for the role management service.
To retrieve your access token:
curl -X POST "https://iam.cloud.ibm.com/identity/token" --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey' --data-urlencode 'apikey=<API_KEY>'
Replace <API_KEY> with your IAM API key.
Setting client options through external configuration
Example environment variables, where <SERVICE_URL> is the endpoint URL and <API_KEY> is your IAM API key
export IAM_POLICY_MANAGEMENT_URL=<SERVICE_URL>
export IAM_POLICY_MANAGEMENT_AUTHTYPE=iam
export IAM_POLICY_MANAGEMENT_APIKEY=<API_KEY>
Example of constructing the service client
import {
"github.com/IBM/platform-services-go-sdk/iampolicymanagementv1"
}
...
serviceClientOptions := &iampolicymanagementv1.IamPolicyManagementV1Options{}
serviceClient, err := iampolicymanagementv1.NewIamPolicyManagementV1UsingExternalConfig(serviceClientOptions)
Setting client options through external configuration
Example environment variables, where <SERVICE_URL> is the endpoint URL and <API_KEY> is your IAM API key
export IAM_POLICY_MANAGEMENT_URL=<SERVICE_URL>
export IAM_POLICY_MANAGEMENT_AUTHTYPE=iam
export IAM_POLICY_MANAGEMENT_APIKEY=<API_KEY>
Example of constructing the service client
import com.ibm.cloud.platform_services.iam_policy_management.v1.IamPolicyManagement;
...
IamPolicyManagement serviceClient = IamPolicyManagement.newInstance();
Setting client options through external configuration
Example environment variables, where <SERVICE_URL> is the endpoint URL and <API_KEY> is your IAM API key
export IAM_POLICY_MANAGEMENT_URL=<SERVICE_URL>
export IAM_POLICY_MANAGEMENT_AUTHTYPE=iam
export IAM_POLICY_MANAGEMENT_APIKEY=<API_KEY>
Example of constructing the service client
const IamPolicyManagementV1 = require('ibm-platform-services/iam-policy-management/v1');
...
const serviceClient = IamPolicyManagementV1.newInstance({});
Setting client options through external configuration
Example environment variables, where <SERVICE_URL> is the endpoint URL and <API_KEY> is your IAM API key
export IAM_POLICY_MANAGEMENT_URL=<SERVICE_URL>
export IAM_POLICY_MANAGEMENT_AUTHTYPE=iam
export IAM_POLICY_MANAGEMENT_APIKEY=<API_KEY>
Example of constructing the service client
from ibm_platform_services import IamPolicyManagementV1
...
service_client = IamPolicyManagementV1.new_instance()
Auditing
You can monitor API activity within your account by using the IBM Cloud® Activity Tracker service. You can track when specific API methods are called by reviewing generated events in Activity Tracker.
If an event is tracked for a method, you can find it listed with the method. For more information about how to track IAM activity, see Auditing events for IAM.
Error handling
The Policy Management APIs return standard HTTP status codes to indicate the success or failure of a request. The format of the response is represented in JSON as follows:
{
"trace": "cd4f7573121a4cf99f0079f8482b3d6b",
"errors": [
{
"code": "invalid_token",
"message": "The provided IAM token is invalid."
}
],
"status_code": 401
}
If an operation cannot be fulfilled, an appropriate 400 or 500 series HTTP response is returned from the server. The operations that are defined in the Reference section describe example errors that can be returned from a failed request. All responses from the IAM Policy Management API are in the JSON format.
Here are potential error codes that the API can return.
| HTTP Error Code | Description | Recovery |
|---|---|---|
200 |
Success | The request was successful. |
201 |
Created | The resource was successfully created. |
204 |
No Content | The request was successful. No response body is provided. |
400 |
Bad Request | The input parameters in the request body are either incomplete or in the wrong format. Be sure to include all required parameters in your request. |
401 |
Unauthorized | You are not authorized to make this request. The token is either invalid, missing or expired. Get a new valid token and try again. |
403 |
Forbidden | The token is valid, but the subject of the token is not authorized to perform the operation. If this error persists, contact the account owner to check your permissions. |
404 |
Not Found | The requested resource can't be found. |
409 |
Conflict | The entity is already in the requested state. |
415 |
Unsupported Media Type | Request body sent was formatted by using an unsupported media type. |
429 |
Too Many Requests | Too many requests have been made within a given time window. Wait the time in seconds indicated in the Retry-After response header before calling the API again. |
500 |
Service Unavailable | IAM Policy Management Point is currently unavailable. Your request can't be processed. Wait a few minutes and try again. |
Transaction-Id
An optional transaction ID can be passed to your request, which can be useful for tracking calls through multiple services by using one identifier. The header key must be set to Transaction-Id and the value is anything that you choose.
If no transaction ID is passed in, then a random ID is generated.
Sorting
Sorting is available on the policies listing APIs. Use a sort query parameter set to the field name you want the results sorted by. All the top level policy fields are supported.
To reverse sort, add a - prefix to the field name.
For example, for the GET /v1/policies endpoint, a query parameter of sort=last_modified_at sorts the returned policies in ascending date and time order by last_modified_at. Meanwhile a query parameter of sort=-last_modified_at returns the policies in descending date and time order by last_modified_at.
Policy data enrichment
Currently two options are available: display and include_last_permit. By including query parameter format=display, the API returns the list of all actions included in each of the policy roles.
"roles": [
{
"role_id": "crn:v1:bluemix:public:iam::::role:Administrator",
"display_name": "Administrator",
"description": "Administrators can change object metadata or visibility for private services added to the account and can restrict the visibility of a public service.",
"actions": [
{
"id": "global-search-tagging.resource.read",
"displayName": "Find cloud resources",
"description": "The ability to find the resource using Global Search and Tagging search API."
},
{
"id": "iam.policy.read",
"displayName": "IAM Policy Read",
"description": "The ability to see policies."
},
{
"id": "iam.policy.create",
"displayName": "IAM Policy Create",
"description": "The ability to create policies."
}
]
}
],
Including the query parameter format=include_last_permit returns details of when the policy last granted a permit decision and the number of times it has done so.
{
"id": "03b5696c-6844-430f-a3b1-8f2d0de53218",
"type": "access",
"subjects": ...,
"roles": ...,
"resources": ...,
"last_permit_at": "2020-10-16T22:17:40.832Z",
"last_permit_frequency": 18
},
This data is provided for informational purposes only. The last permit data only include records begining from end of October 2020.
Methods
Get policies by attributes
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
GET /v1/policies
(iamPolicyManagement *IamPolicyManagementV1) ListPolicies(listPoliciesOptions *ListPoliciesOptions) (result *PolicyCollection, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ListPoliciesWithContext(ctx context.Context, listPoliciesOptions *ListPoliciesOptions) (result *PolicyCollection, response *core.DetailedResponse, err error)
ServiceCall<PolicyCollection> listPolicies(ListPoliciesOptions listPoliciesOptions)listPolicies(params)
list_policies(
self,
account_id: str,
*,
accept_language: Optional[str] = None,
iam_id: Optional[str] = None,
access_group_id: Optional[str] = None,
type: Optional[str] = None,
service_type: Optional[str] = None,
tag_name: Optional[str] = None,
tag_value: Optional[str] = None,
sort: Optional[str] = None,
format: Optional[str] = None,
state: Optional[str] = None,
limit: Optional[int] = None,
start: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ListPoliciesOptions struct and set the fields to provide parameter values for the ListPolicies method.
Use the ListPoliciesOptions.Builder to create a ListPoliciesOptions object that contains the parameter values for the listPolicies method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
Query Parameters
The account GUID that the policies belong to.
Optional IAM ID used to identify the subject.
Optional access group id.
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of the access tag in the policy.
Optional value of the access tag in the policy.
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field. Example '-last_modified_at'
Allowable values: [
type,href,created_at,created_by_id,last_modified_at,last_modified_by_id,state]Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
^[-A-Za-z0-9+/]*$
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ListPolicies options.
The account GUID that the policies belong to.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Optional access group id.
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of the access tag in the policy.
Optional value of the access tag in the policy.
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field. Example '-last_modified_at'.
Allowable values: [
type,href,created_at,created_by_id,last_modified_at,last_modified_by_id,state]Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Examples:10Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
The listPolicies options.
The account GUID that the policies belong to.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Optional access group id.
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of the access tag in the policy.
Optional value of the access tag in the policy.
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field. Example '-last_modified_at'.
Allowable values: [
type,href,created_at,created_by_id,last_modified_at,last_modified_by_id,state]Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Examples:10Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
parameters
The account GUID that the policies belong to.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Optional access group id.
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of the access tag in the policy.
Optional value of the access tag in the policy.
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field. Example '-last_modified_at'.
Allowable values: [
type,href,created_at,created_by_id,last_modified_at,last_modified_by_id,state]Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
parameters
The account GUID that the policies belong to.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Optional access group id.
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of the access tag in the policy.
Optional value of the access tag in the policy.
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field. Example '-last_modified_at'.
Allowable values: [
type,href,created_at,created_by_id,last_modified_at,last_modified_by_id,state]Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
curl -X GET 'https://iam.cloud.ibm.com/v1/policies?account_id=$ACCOUNT_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewListPoliciesOptions( exampleAccountID, ) options.SetIamID(exampleUserID) options.SetFormat("include_last_permit") policyList, response, err := iamPolicyManagementService.ListPolicies(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policyList, "", " ") fmt.Println(string(b))
ListPoliciesOptions options = new ListPoliciesOptions.Builder() .accountId(exampleAccountId) .iamId(EXAMPLE_USER_ID) .format("include_last_permit") .build(); Response<PolicyCollection> response = service.listPolicies(options).execute(); PolicyCollection policyCollection = response.getResult(); System.out.println(policyCollection);
const params = { accountId: exampleAccountId, iamId: exampleUserId, format: 'include_last_permit', }; try { const res = await iamPolicyManagementService.listPolicies(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
policy_list = iam_policy_management_service.list_policies( account_id=example_account_id, iam_id=example_user_id, format='include_last_permit' ).get_result() print(json.dumps(policy_list, indent=2))
Response
A collection of policies.
List of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
Details with href linking to the following page of requested collection.
Details with linking href to previous page of requested collection.
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- First
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- Next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- Previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
- Policies
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- Template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
- policies
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
- policies
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
- policies
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
Status Code
Policies retrieval successful.
The request you made is not valid.
The token that you provided is not valid.
The requested resource(s) cannot be formatted that uses the requested media type(s).
Too many requests are within a time window.
{ "policies": [ { "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" } ] }{ "policies": [ { "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "missing_required_query_parameter", "message": "'account_id' is a required query parameter" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "missing_required_query_parameter", "message": "'account_id' is a required query parameter" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Create a policy
Creates a policy to grant access between a subject and a resource. There are two types of policies: access and authorization. A policy administrator might want to create an access policy which grants access to a user, service-id, or an access group. They might also want to create an authorization policy and setup access between services.
Access
To create an access policy, use "type": "access" in the body.
The possible subject attributes are iam_id and access_group_id.
Use the iam_id subject attribute for assigning access for a user or service-id.
Use the access_group_id subject attribute for assigning access for an access group.
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute.
The IAM Services group (IAM) is a subset of account management services that includes the IAM platform services IAM Identity, IAM Access Management, IAM Users Management, IAM Groups, and future IAM services.
If the subject is a locked service-id, the request will fail.
Authorization
Authorization policies are supported by services on a case by case basis.
Refer to service documentation to verify their support of authorization policies.
To create an authorization policy, use "type": "authorization" in the body.
The subject attributes must match the supported authorization subjects of the resource.
Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
The user must also have the same level of access or greater to the target resource in order to grant the role.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes may support one or both operators.
For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. There are two types of policies: access and authorization. A policy administrator might want to create an access policy which grants access to a user, service-id, or an access group. They might also want to create an authorization policy and setup access between services.
Access
To create an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. The IAM Services group (IAM) is a subset of account management services that includes the IAM platform services IAM Identity, IAM Access Management, IAM Users Management, IAM Groups, and future IAM services. If the subject is a locked service-id, the request will fail.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes may support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. There are two types of policies: access and authorization. A policy administrator might want to create an access policy which grants access to a user, service-id, or an access group. They might also want to create an authorization policy and setup access between services.
Access
To create an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. The IAM Services group (IAM) is a subset of account management services that includes the IAM platform services IAM Identity, IAM Access Management, IAM Users Management, IAM Groups, and future IAM services. If the subject is a locked service-id, the request will fail.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes may support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. There are two types of policies: access and authorization. A policy administrator might want to create an access policy which grants access to a user, service-id, or an access group. They might also want to create an authorization policy and setup access between services.
Access
To create an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. The IAM Services group (IAM) is a subset of account management services that includes the IAM platform services IAM Identity, IAM Access Management, IAM Users Management, IAM Groups, and future IAM services. If the subject is a locked service-id, the request will fail.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes may support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. There are two types of policies: access and authorization. A policy administrator might want to create an access policy which grants access to a user, service-id, or an access group. They might also want to create an authorization policy and setup access between services.
Access
To create an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. The IAM Services group (IAM) is a subset of account management services that includes the IAM platform services IAM Identity, IAM Access Management, IAM Users Management, IAM Groups, and future IAM services. If the subject is a locked service-id, the request will fail.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes may support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
POST /v1/policies
(iamPolicyManagement *IamPolicyManagementV1) CreatePolicy(createPolicyOptions *CreatePolicyOptions) (result *Policy, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) CreatePolicyWithContext(ctx context.Context, createPolicyOptions *CreatePolicyOptions) (result *Policy, response *core.DetailedResponse, err error)
ServiceCall<Policy> createPolicy(CreatePolicyOptions createPolicyOptions)createPolicy(params)
create_policy(
self,
type: str,
subjects: List['PolicySubject'],
roles: List['PolicyRole'],
resources: List['PolicyResource'],
*,
description: Optional[str] = None,
accept_language: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the CreatePolicyOptions struct and set the fields to provide parameter values for the CreatePolicy method.
Use the CreatePolicyOptions.Builder to create a CreatePolicyOptions object that contains the parameter values for the createPolicy method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
A policy to be created.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
^[a-z]+$The subjects associated with a policy.
Possible values: number of items = 1
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
The resources associated with a policy.
Possible values: number of items = 1
Customer-defined description
Possible values: 1 ≤ length ≤ 300
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The CreatePolicy options.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
The createPolicy options.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
parameters
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
parameters
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
curl -X POST 'https://iam.cloud.ibm.com/v1/policies' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -d '{ "type": "access", "description": "Editor role for SERVICE_NAME\'s RESOURCE_NAME", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles":[ { "role_id": "crn:v1:bluemix:public:iam::::role:Editor" } ], "resources":[ { "attributes": [ { "name": "accountId", "value": "$ACCOUNT_ID" }, { "name": "serviceName", "value": "$SERVICE_NAME" }, { "name": "resource", "value": "$RESOURCE_NAME", "operator": "stringEquals" } ] } ] }'
subjectAttribute := &iampolicymanagementv1.SubjectAttribute{ Name: core.StringPtr("iam_id"), Value: &exampleUserID, } policySubjects := &iampolicymanagementv1.PolicySubject{ Attributes: []iampolicymanagementv1.SubjectAttribute{*subjectAttribute}, } policyRoles := &iampolicymanagementv1.PolicyRole{ RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Viewer"), } accountIDResourceAttribute := &iampolicymanagementv1.ResourceAttribute{ Name: core.StringPtr("accountId"), Value: core.StringPtr(exampleAccountID), Operator: core.StringPtr("stringEquals"), } serviceNameResourceAttribute := &iampolicymanagementv1.ResourceAttribute{ Name: core.StringPtr("serviceType"), Value: core.StringPtr("service"), Operator: core.StringPtr("stringEquals"), } policyResourceTag := &iampolicymanagementv1.ResourceTag{ Name: core.StringPtr("project"), Value: core.StringPtr("prototype"), Operator: core.StringPtr("stringEquals"), } policyResources := &iampolicymanagementv1.PolicyResource{ Attributes: []iampolicymanagementv1.ResourceAttribute{ *accountIDResourceAttribute, *serviceNameResourceAttribute}, Tags: []iampolicymanagementv1.ResourceTag{*policyResourceTag}, } options := iamPolicyManagementService.NewCreatePolicyOptions( "access", []iampolicymanagementv1.PolicySubject{*policySubjects}, []iampolicymanagementv1.PolicyRole{*policyRoles}, []iampolicymanagementv1.PolicyResource{*policyResources}, ) policy, response, err := iamPolicyManagementService.CreatePolicy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") examplePolicyID = *policy.ID fmt.Println(string(b))
SubjectAttribute subjectAttribute = new SubjectAttribute.Builder() .name("iam_id") .value(EXAMPLE_USER_ID) .build(); PolicySubject policySubjects = new PolicySubject.Builder() .addAttributes(subjectAttribute) .build(); PolicyRole policyRoles = new PolicyRole.Builder() .roleId("crn:v1:bluemix:public:iam::::role:Viewer") .build(); ResourceAttribute accountIdResourceAttribute = new ResourceAttribute.Builder() .name("accountId") .value(exampleAccountId) .operator("stringEquals") .build(); ResourceAttribute serviceNameResourceAttribute = new ResourceAttribute.Builder() .name("serviceType") .value("service") .operator("stringEquals") .build(); ResourceTag policyResourceTag = new ResourceTag.Builder() .name("project") .value("prototype") .operator("stringEquals") .build(); PolicyResource policyResources = new PolicyResource.Builder() .addAttributes(accountIdResourceAttribute) .addAttributes(serviceNameResourceAttribute) .addTags(policyResourceTag) .build(); CreatePolicyOptions options = new CreatePolicyOptions.Builder() .type("access") .subjects(Arrays.asList(policySubjects)) .roles(Arrays.asList(policyRoles)) .resources(Arrays.asList(policyResources)) .build(); Response<Policy> response = service.createPolicy(options).execute(); Policy policy = response.getResult(); examplePolicyId = policy.getId(); System.out.println(policy);
const policySubjects = [ { attributes: [ { name: 'iam_id', value: exampleUserId, }, ], }, ]; const policyRoles = [ { role_id: 'crn:v1:bluemix:public:iam::::role:Viewer', }, ]; const accountIdResourceAttribute = { name: 'accountId', value: exampleAccountId, operator: 'stringEquals', }; const serviceNameResourceAttribute = { name: 'serviceType', value: 'service', operator: 'stringEquals', }; const policyResourceTag = { name: 'project', operator: 'stringEquals', value: 'prototype', }; const policyResources = [ { attributes: [accountIdResourceAttribute, serviceNameResourceAttribute], tags: [policyResourceTag], }, ]; const params = { type: 'access', subjects: policySubjects, roles: policyRoles, resources: policyResources, }; try { const res = await iamPolicyManagementService.createPolicy(params); examplePolicyId = res.result.id; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
policy_subjects = PolicySubject(attributes=[SubjectAttribute(name='iam_id', value=example_user_id)]) policy_roles = PolicyRole(role_id='crn:v1:bluemix:public:iam::::role:Viewer') account_id_resource_attribute = ResourceAttribute(name='accountId', value=example_account_id) service_name_resource_attribute = ResourceAttribute(name='serviceType', value='service') policy_resource_tag = ResourceTag(name='project', value='prototype') policy_resources = PolicyResource( attributes=[account_id_resource_attribute, service_name_resource_attribute], tags=[policy_resource_tag] ) policy = iam_policy_management_service.create_policy( type='access', subjects=[policy_subjects], roles=[policy_roles], resources=[policy_resources] ).get_result() global example_policy_id example_policy_id = policy['id'] print(json.dumps(policy, indent=2))
Response
The core set of properties associated with a policy.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
^[a-z]+$The subjects associated with a policy.
Possible values: number of items = 1
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
The resources associated with a policy.
Possible values: number of items = 1
The policy ID.
Customer-defined description
Possible values: 1 ≤ length ≤ 300
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
Status Code
Policy creation successful.
Policy input is invalid.
The token that you provided is not valid.
You do not have access to create the policy.
The requested resource(s) cannot be formatted that uses the requested media type(s).
A policy already exists for the given subject and resource. You can update that policy or delete it and create a new one.
The request body sent was formatted that uses an unsupported media type.
Exceeded maximum policies quota.
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ], "tags": [ { "name": "project", "value": "moonshot", "operator": "stringEquals" }, { "name": "pipeline", "value": "test", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ], "tags": [ { "name": "project", "value": "moonshot", "operator": "stringEquals" }, { "name": "pipeline", "value": "test", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Invalid body format. Check the input parameters." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Invalid body format. Check the input parameters." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to create the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to create the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to create policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to create policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "request_not_processed", "message": "Exceeded maximum policies quota (<limit>) for account <account_id>." } ], "status_code": 422 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "request_not_processed", "message": "Exceeded maximum policies quota (<limit>) for account <account_id>." } ], "status_code": 422 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Update a policy
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy. The policy type cannot be changed (You cannot change an access policy to an authorization policy).
Access
To update an access policy, use "type": "access" in the body.
The possible subject attributes are iam_id and access_group_id.
Use the iam_id subject attribute for assigning access for a user or service-id.
Use the access_group_id subject attribute for assigning access for an access group.
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
The policy resource must include either the serviceType, serviceName, or resourceGroupId attribute and the accountId attribute.`
If the subject is a locked service-id, the request will fail.
Authorization
To update an authorization policy, use "type": "authorization" in the body.
The subject attributes must match the supported authorization subjects of the resource.
Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
The user must also have the same level of access or greater to the target resource in order to grant the role.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes might support one or both operators.
For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy. The policy type cannot be changed (You cannot change an access policy to an authorization policy).
Access
To update an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, or resourceGroupId attribute and the accountId attribute.` If the subject is a locked service-id, the request will fail.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes might support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy. The policy type cannot be changed (You cannot change an access policy to an authorization policy).
Access
To update an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, or resourceGroupId attribute and the accountId attribute.` If the subject is a locked service-id, the request will fail.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes might support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy. The policy type cannot be changed (You cannot change an access policy to an authorization policy).
Access
To update an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, or resourceGroupId attribute and the accountId attribute.` If the subject is a locked service-id, the request will fail.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes might support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy. The policy type cannot be changed (You cannot change an access policy to an authorization policy).
Access
To update an access policy, use "type": "access" in the body. The possible subject attributes are iam_id and access_group_id. Use the iam_id subject attribute for assigning access for a user or service-id. Use the access_group_id subject attribute for assigning access for an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, or resourceGroupId attribute and the accountId attribute.` If the subject is a locked service-id, the request will fail.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals and the stringMatch operators are available. Resource attributes might support one or both operators. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
PUT /v1/policies/{policy_id}(iamPolicyManagement *IamPolicyManagementV1) ReplacePolicy(replacePolicyOptions *ReplacePolicyOptions) (result *Policy, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ReplacePolicyWithContext(ctx context.Context, replacePolicyOptions *ReplacePolicyOptions) (result *Policy, response *core.DetailedResponse, err error)
ServiceCall<Policy> replacePolicy(ReplacePolicyOptions replacePolicyOptions)replacePolicy(params)
replace_policy(
self,
policy_id: str,
if_match: str,
type: str,
subjects: List['PolicySubject'],
roles: List['PolicyRole'],
resources: List['PolicyResource'],
*,
description: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ReplacePolicyOptions struct and set the fields to provide parameter values for the ReplacePolicy method.
Use the ReplacePolicyOptions.Builder to create a ReplacePolicyOptions object that contains the parameter values for the replacePolicy method.
Custom Headers
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
Path Parameters
The policy ID.
Updated policy content to be saved.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
^[a-z]+$The subjects associated with a policy.
Possible values: number of items = 1
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
The resources associated with a policy.
Possible values: number of items = 1
Customer-defined description
Possible values: 1 ≤ length ≤ 300
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ReplacePolicy options.
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The replacePolicy options.
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
parameters
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
parameters
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
Customer-defined description.
Possible values: 1 ≤ length ≤ 300
curl -X PUT 'https://iam.cloud.ibm.com/v1/policies' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -H 'If-Match: $ETAG' -d '{ "type": "access", "description": "Viewer role for for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles":[ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources":[ { "attributes": [ { "name": "accountId", "value": "$ACCOUNT_ID" }, { "name": "serviceName", "value": "$SERVICE_NAME" } ] } ] }'
subjectAttribute := &iampolicymanagementv1.SubjectAttribute{ Name: core.StringPtr("iam_id"), Value: &exampleUserID, } policySubjects := &iampolicymanagementv1.PolicySubject{ Attributes: []iampolicymanagementv1.SubjectAttribute{*subjectAttribute}, } accountIDResourceAttribute := &iampolicymanagementv1.ResourceAttribute{ Name: core.StringPtr("accountId"), Value: core.StringPtr(exampleAccountID), Operator: core.StringPtr("stringEquals"), } serviceNameResourceAttribute := &iampolicymanagementv1.ResourceAttribute{ Name: core.StringPtr("serviceType"), Value: core.StringPtr("service"), Operator: core.StringPtr("stringEquals"), } policyResourceTag := &iampolicymanagementv1.ResourceTag{ Name: core.StringPtr("project"), Value: core.StringPtr("prototype"), Operator: core.StringPtr("stringEquals"), } policyResources := &iampolicymanagementv1.PolicyResource{ Attributes: []iampolicymanagementv1.ResourceAttribute{ *accountIDResourceAttribute, *serviceNameResourceAttribute}, Tags: []iampolicymanagementv1.ResourceTag{*policyResourceTag}, } updatedPolicyRoles := &iampolicymanagementv1.PolicyRole{ RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Editor"), } options := iamPolicyManagementService.NewReplacePolicyOptions( examplePolicyID, examplePolicyETag, "access", []iampolicymanagementv1.PolicySubject{*policySubjects}, []iampolicymanagementv1.PolicyRole{*updatedPolicyRoles}, []iampolicymanagementv1.PolicyResource{*policyResources}, ) policy, response, err := iamPolicyManagementService.ReplacePolicy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") examplePolicyETag = response.GetHeaders().Get("ETag") fmt.Println(string(b))
SubjectAttribute subjectAttribute = new SubjectAttribute.Builder() .name("iam_id") .value(EXAMPLE_USER_ID) .build(); PolicySubject policySubjects = new PolicySubject.Builder() .addAttributes(subjectAttribute) .build(); ResourceAttribute accountIdResourceAttribute = new ResourceAttribute.Builder() .name("accountId") .value(exampleAccountId) .operator("stringEquals") .build(); ResourceAttribute serviceNameResourceAttribute = new ResourceAttribute.Builder() .name("serviceType") .value("service") .operator("stringEquals") .build(); ResourceTag policyResourceTag = new ResourceTag.Builder() .name("project") .value("prototype") .operator("stringEquals") .build(); PolicyResource policyResources = new PolicyResource.Builder() .addAttributes(accountIdResourceAttribute) .addAttributes(serviceNameResourceAttribute) .addTags(policyResourceTag) .build(); PolicyRole updatedPolicyRole = new PolicyRole.Builder() .roleId("crn:v1:bluemix:public:iam::::role:Editor") .build(); ReplacePolicyOptions options = new ReplacePolicyOptions.Builder() .type("access") .policyId(examplePolicyId) .ifMatch(examplePolicyEtag) .subjects(new ArrayList<PolicySubject>(Arrays.asList(policySubjects))) .roles(new ArrayList<PolicyRole>(Arrays.asList(updatedPolicyRole))) .resources(new ArrayList<PolicyResource>(Arrays.asList(policyResources))) .build(); Response<Policy> response = service.replacePolicy(options).execute(); Policy policy = response.getResult(); examplePolicyEtag = response.getHeaders().values("Etag").get(0); System.out.println(policy);
const policySubjects = [ { attributes: [ { name: 'iam_id', value: exampleUserId, }, ], }, ]; const accountIdResourceAttribute = { name: 'accountId', value: exampleAccountId, operator: 'stringEquals', }; const serviceNameResourceAttribute = { name: 'serviceType', value: 'service', operator: 'stringEquals', }; const policyResourceTag = { name: 'project', operator: 'stringEquals', value: 'prototype', }; const policyResources = [ { attributes: [accountIdResourceAttribute, serviceNameResourceAttribute], tags: [policyResourceTag], }, ]; const updatedPolicyRoles = [ { role_id: 'crn:v1:bluemix:public:iam::::role:Editor', }, ]; const params = { type: 'access', policyId: examplePolicyId, ifMatch: examplePolicyETag, subjects: policySubjects, roles: updatedPolicyRoles, resources: policyResources, }; try { const res = await iamPolicyManagementService.replacePolicy(params); examplePolicyETag = res.headers.etag; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
policy_subjects = PolicySubject(attributes=[SubjectAttribute(name='iam_id', value=example_user_id)]) account_id_resource_attribute = ResourceAttribute(name='accountId', value=example_account_id) service_name_resource_attribute = ResourceAttribute(name='serviceType', value='service') policy_resource_tag = ResourceTag(name='project', value='prototype') policy_resources = PolicyResource( attributes=[account_id_resource_attribute, service_name_resource_attribute], tags=[policy_resource_tag] ) updated_policy_roles = PolicyRole(role_id='crn:v1:bluemix:public:iam::::role:Editor') response = iam_policy_management_service.replace_policy( type='access', policy_id=example_policy_id, if_match=example_policy_etag, subjects=[policy_subjects], roles=[updated_policy_roles], resources=[policy_resources], ) policy = response.get_result() global example_updated_policy_etag example_updated_policy_etag = response.get_headers().get("Etag") print(json.dumps(policy, indent=2))
Response
The core set of properties associated with a policy.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
^[a-z]+$The subjects associated with a policy.
Possible values: number of items = 1
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
The resources associated with a policy.
Possible values: number of items = 1
The policy ID.
Customer-defined description
Possible values: 1 ≤ length ≤ 300
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
Status Code
Policy update successful.
Policy input is invalid.
The token that you provided is not valid.
You do not have access to update the policy.
The policy was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
A policy already exists for the given subject and resource. You can update that policy or delete it and create a new one.
The request body sent was formatted that uses an unsupported media type.
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "A policy's type cannot be updated. Create a new policy and delete the existing one." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "A policy's type cannot be updated. Create a new policy and delete the existing one." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to update policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to update policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Retrieve a policy by ID
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
GET /v1/policies/{policy_id}(iamPolicyManagement *IamPolicyManagementV1) GetPolicy(getPolicyOptions *GetPolicyOptions) (result *PolicyTemplateMetaData, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) GetPolicyWithContext(ctx context.Context, getPolicyOptions *GetPolicyOptions) (result *PolicyTemplateMetaData, response *core.DetailedResponse, err error)
ServiceCall<PolicyTemplateMetaData> getPolicy(GetPolicyOptions getPolicyOptions)getPolicy(params)
get_policy(
self,
policy_id: str,
**kwargs,
) -> DetailedResponseRequest
Instantiate the GetPolicyOptions struct and set the fields to provide parameter values for the GetPolicy method.
Use the GetPolicyOptions.Builder to create a GetPolicyOptions object that contains the parameter values for the getPolicy method.
Path Parameters
The policy ID.
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The GetPolicy options.
The policy ID.
The getPolicy options.
The policy ID.
parameters
The policy ID.
parameters
The policy ID.
curl -X GET 'https://iam.cloud.ibm.com/v1/policies/$POLICY_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewGetPolicyOptions( examplePolicyID, ) policy, response, err := iamPolicyManagementService.GetPolicy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") examplePolicyETag = response.GetHeaders().Get("ETag") fmt.Println(string(b))
GetPolicyOptions options = new GetPolicyOptions.Builder() .policyId(examplePolicyId) .build(); Response<PolicyTemplateMetaData> response = service.getPolicy(options).execute(); PolicyTemplateMetaData policy = response.getResult(); examplePolicyEtag = response.getHeaders().values("Etag").get(0); System.out.println(policy);
const params = { policyId: examplePolicyId, }; try { const res = await iamPolicyManagementService.getPolicy(params); examplePolicyETag = res.headers.etag; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
response = iam_policy_management_service.get_policy(policy_id=example_policy_id) policy = response.get_result() global example_policy_etag example_policy_etag = response.get_headers().get("Etag") print(json.dumps(policy, indent=2))
Response
The core set of properties associated with a policy.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
^[a-z]+$The subjects associated with a policy.
Possible values: number of items = 1
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
The resources associated with a policy.
Possible values: number of items = 1
The policy ID.
Customer-defined description
Possible values: 1 ≤ length ≤ 300
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- Template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
Status Code
Policy retrieval successful.
The token that you provided is not valid.
You do not have access to retrieve the policy.
The policy was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to retrieve the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to retrieve the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Delete a policy by ID
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
DELETE /v1/policies/{policy_id}(iamPolicyManagement *IamPolicyManagementV1) DeletePolicy(deletePolicyOptions *DeletePolicyOptions) (response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) DeletePolicyWithContext(ctx context.Context, deletePolicyOptions *DeletePolicyOptions) (response *core.DetailedResponse, err error)
ServiceCall<Void> deletePolicy(DeletePolicyOptions deletePolicyOptions)deletePolicy(params)
delete_policy(
self,
policy_id: str,
**kwargs,
) -> DetailedResponseRequest
Instantiate the DeletePolicyOptions struct and set the fields to provide parameter values for the DeletePolicy method.
Use the DeletePolicyOptions.Builder to create a DeletePolicyOptions object that contains the parameter values for the deletePolicy method.
Path Parameters
The policy ID.
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The DeletePolicy options.
The policy ID.
The deletePolicy options.
The policy ID.
parameters
The policy ID.
parameters
The policy ID.
curl -X DELETE 'https://iam.cloud.ibm.com/v1/policies/$POLICY_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewDeletePolicyOptions( examplePolicyID, ) response, err := iamPolicyManagementService.DeletePolicy(options) if err != nil { panic(err) }
DeletePolicyOptions options = new DeletePolicyOptions.Builder() .policyId(examplePolicyId) .build(); Response<Void> response = service.deletePolicy(options).execute();
const params = { policyId: examplePolicyId, }; try { await iamPolicyManagementService.deletePolicy(params); } catch (err) { console.warn(err); }
response = iam_policy_management_service.delete_policy(policy_id=example_policy_id).get_result() print(json.dumps(response, indent=2))
Response
Status Code
Policy deletion successful.
Policy was not valid to delete.
The token that you provided is not valid.
You do not have access to delete the policy.
The policy was not found.
Too many requests are within a time window.
{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Request includes a locked service id, cannot perform action" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Request includes a locked service id, cannot perform action" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to delete the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to delete the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Restore a deleted policy by ID
Restore a policy that has recently been deleted.
A policy administrator might want to restore a deleted policy.
To restore a policy, use "state": "active" in the body.
Restore a policy that has recently been deleted. A policy administrator might want to restore a deleted policy. To restore a policy, use "state": "active" in the body.
Restore a policy that has recently been deleted. A policy administrator might want to restore a deleted policy. To restore a policy, use "state": "active" in the body.
Restore a policy that has recently been deleted. A policy administrator might want to restore a deleted policy. To restore a policy, use "state": "active" in the body.
Restore a policy that has recently been deleted. A policy administrator might want to restore a deleted policy. To restore a policy, use "state": "active" in the body.
PATCH /v1/policies/{policy_id}(iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyState(updatePolicyStateOptions *UpdatePolicyStateOptions) (result *Policy, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) UpdatePolicyStateWithContext(ctx context.Context, updatePolicyStateOptions *UpdatePolicyStateOptions) (result *Policy, response *core.DetailedResponse, err error)
ServiceCall<Policy> updatePolicyState(UpdatePolicyStateOptions updatePolicyStateOptions)updatePolicyState(params)
update_policy_state(
self,
policy_id: str,
if_match: str,
*,
state: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the UpdatePolicyStateOptions struct and set the fields to provide parameter values for the UpdatePolicyState method.
Use the UpdatePolicyStateOptions.Builder to create a UpdatePolicyStateOptions object that contains the parameter values for the updatePolicyState method.
Custom Headers
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
Path Parameters
The policy ID.
Policy attribute to be updated.
The policy state.
Allowable values: [
active,deleted]
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The UpdatePolicyState options.
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy state.
Allowable values: [
active,deleted]
The updatePolicyState options.
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy state.
Allowable values: [
active,deleted]
parameters
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy state.
Allowable values: [
active,deleted]
parameters
The policy ID.
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v1/policies/{policy_id} API and looking at the ETag response header.
The policy state.
Allowable values: [
active,deleted]
curl -X PATCH 'https://iam.cloud.ibm.com/v1/policies' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -H 'If-Match: $ETAG' -d '{ "state": "active", }'
options := iamPolicyManagementService.NewUpdatePolicyStateOptions( examplePolicyID, examplePolicyETag, ) options.SetState("active") policy, response, err := iamPolicyManagementService.UpdatePolicyState(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b))
UpdatePolicyStateOptions updatePolicyStateOptions = new UpdatePolicyStateOptions.Builder() .policyId(examplePolicyId) .ifMatch(examplePolicyEtag) .state("active") .build(); Response<Policy> response = service.updatePolicyState(updatePolicyStateOptions).execute(); Policy policy = response.getResult(); System.out.println(policy);
const params = { policyId: examplePolicyId, ifMatch: examplePolicyETag, state: 'active' }; try { const res = await iamPolicyManagementService.updatePolicyState(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
policy = iam_policy_management_service.update_policy_state( policy_id=example_policy_id, if_match=example_updated_policy_etag, state='active' ).get_result() print(json.dumps(policy, indent=2))
Response
The core set of properties associated with a policy.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
^[a-z]+$The subjects associated with a policy.
Possible values: number of items = 1
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
The resources associated with a policy.
Possible values: number of items = 1
The policy ID.
Customer-defined description
Possible values: 1 ≤ length ≤ 300
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- Subjects
List of subject attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- Resources
List of resource attributes.
Possible values: number of items ≥ 1
- Attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
The core set of properties associated with a policy.
The policy ID.
The policy type; either 'access' or 'authorization'.
Possible values: 6 ≤ length ≤ 13, Value must match regular expression
/^[a-z]+$/Customer-defined description.
Possible values: 1 ≤ length ≤ 300
The subjects associated with a policy.
Possible values: number of items = 1
- subjects
List of subject attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The display name of the role.
Possible values: 1 ≤ length ≤ 50, Value must match regular expression
/^((?!<|>).)*$/The description of the role.
Possible values: length ≤ 250
The resources associated with a policy.
Possible values: number of items = 1
- resources
List of resource attributes.
Possible values: number of items ≥ 1
- attributes
The name of an attribute.
The value of an attribute.
Possible values: 1 ≤ length ≤ 1000
The operator of an attribute.
Possible values: length ≥ 1
List of access management tags.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: length ≥ 1
The href links back to the policy.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state.
Possible values: [
active,deleted]
Status Code
Policy successfully restored.
Policy input is invalid.
The token that you provided is not valid.
You do not have access to update the policy.
The policy was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
The request body sent was formatted that uses an unsupported media type.
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of SERVICE_NAME in the account.", "subjects": [ { "attributes": [ { "name": "iam_id", "value": "IBMid-123453user" } ] } ], "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ], "resources": [ { "attributes": [ { "name": "accountId", "value": "ACCOUNT_ID", "operator": "stringEquals" }, { "name": "serviceName", "value": "SERVICE_NAME", "operator": "stringEquals" } ] } ], "href": "https://iam.cloud.ibm.com/v1/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Invalid body format. Check missing parameters." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Invalid body format. Check missing parameters." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Get roles by filters
Get roles based on the filters. While managing roles, you may want to retrieve roles and filter by usages. This can be done through query parameters. Currently, we only support the following attributes: account_id, service_name, service_group_id, source_service_name and policy_type. Both service_name and service_group_id attributes are mutually exclusive. Only roles that match the filter and that the caller has read access to are returned. If the caller does not have read access to any roles an empty array is returned.
Get roles based on the filters. While managing roles, you may want to retrieve roles and filter by usages. This can be done through query parameters. Currently, we only support the following attributes: account_id, service_name, service_group_id, source_service_name and policy_type. Both service_name and service_group_id attributes are mutually exclusive. Only roles that match the filter and that the caller has read access to are returned. If the caller does not have read access to any roles an empty array is returned.
Get roles based on the filters. While managing roles, you may want to retrieve roles and filter by usages. This can be done through query parameters. Currently, we only support the following attributes: account_id, service_name, service_group_id, source_service_name and policy_type. Both service_name and service_group_id attributes are mutually exclusive. Only roles that match the filter and that the caller has read access to are returned. If the caller does not have read access to any roles an empty array is returned.
Get roles based on the filters. While managing roles, you may want to retrieve roles and filter by usages. This can be done through query parameters. Currently, we only support the following attributes: account_id, service_name, service_group_id, source_service_name and policy_type. Both service_name and service_group_id attributes are mutually exclusive. Only roles that match the filter and that the caller has read access to are returned. If the caller does not have read access to any roles an empty array is returned.
Get roles based on the filters. While managing roles, you may want to retrieve roles and filter by usages. This can be done through query parameters. Currently, we only support the following attributes: account_id, service_name, service_group_id, source_service_name and policy_type. Both service_name and service_group_id attributes are mutually exclusive. Only roles that match the filter and that the caller has read access to are returned. If the caller does not have read access to any roles an empty array is returned.
GET /v2/roles
(iamPolicyManagement *IamPolicyManagementV1) ListRoles(listRolesOptions *ListRolesOptions) (result *RoleCollection, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ListRolesWithContext(ctx context.Context, listRolesOptions *ListRolesOptions) (result *RoleCollection, response *core.DetailedResponse, err error)
ServiceCall<RoleCollection> listRoles(ListRolesOptions listRolesOptions)listRoles(params)
list_roles(
self,
*,
accept_language: Optional[str] = None,
account_id: Optional[str] = None,
service_name: Optional[str] = None,
source_service_name: Optional[str] = None,
policy_type: Optional[str] = None,
service_group_id: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ListRolesOptions struct and set the fields to provide parameter values for the ListRoles method.
Use the ListRolesOptions.Builder to create a ListRolesOptions object that contains the parameter values for the listRoles method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
Query Parameters
Optional account GUID in which the roles belong to.
Optional name of IAM enabled service.
Example:
iam-groupsOptional name of source IAM enabled service.
Example:
iam-groupsOptional Policy Type.
Example:
authorizationOptional id of service group.
Example:
IAM
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ListRoles options.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional account GUID in which the roles belong to.
Optional name of IAM enabled service.
Examples:iam-groups
Optional name of source IAM enabled service.
Examples:iam-groups
Optional Policy Type.
Examples:authorization
Optional id of service group.
Examples:IAM
The listRoles options.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional account GUID in which the roles belong to.
Optional name of IAM enabled service.
Examples:iam-groups
Optional name of source IAM enabled service.
Examples:iam-groups
Optional Policy Type.
Examples:authorization
Optional id of service group.
Examples:IAM
parameters
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional account GUID in which the roles belong to.
Optional name of IAM enabled service.
Examples:Optional name of source IAM enabled service.
Examples:Optional Policy Type.
Examples:Optional id of service group.
Examples:
parameters
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional account GUID in which the roles belong to.
Optional name of IAM enabled service.
Examples:Optional name of source IAM enabled service.
Examples:Optional Policy Type.
Examples:Optional id of service group.
Examples:
curl -X GET 'https://iam.cloud.ibm.com/v2/roles' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewListRolesOptions() options.SetAccountID(exampleAccountID) roleList, response, err := iamPolicyManagementService.ListRoles(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(roleList, "", " ") fmt.Println(string(b))
ListRolesOptions options = new ListRolesOptions.Builder() .accountId(exampleAccountId) .build(); Response<RoleCollection> response = service.listRoles(options).execute(); RoleCollection roleCollection = response.getResult(); System.out.println(roleCollection);
const params = { accountId: exampleAccountId, }; try { const res = await iamPolicyManagementService.listRoles(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
role_list = iam_policy_management_service.list_roles(account_id=example_account_id).get_result() print(json.dumps(role_list, indent=2))
Response
A collection of roles returned by the 'list roles' operation.
List of custom roles.
List of service roles.
List of system roles.
A collection of roles returned by the 'list roles' operation.
List of custom roles.
- CustomRoles
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
List of service roles.
- ServiceRoles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
List of system roles.
- SystemRoles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
A collection of roles returned by the 'list roles' operation.
List of custom roles.
- customRoles
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
List of service roles.
- serviceRoles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
List of system roles.
- systemRoles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
A collection of roles returned by the 'list roles' operation.
List of custom roles.
- custom_roles
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
List of service roles.
- service_roles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
List of system roles.
- system_roles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
A collection of roles returned by the 'list roles' operation.
List of custom roles.
- custom_roles
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
List of service roles.
- service_roles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
List of system roles.
- system_roles
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
Status Code
Roles retrieval successful.
The token that you provided is not valid.
Resource was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
Too many requests are within a time window.
{ "custom_roles": [ { "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" } ], "service_roles": [ { "crn": "crn:v1:bluemix:public:iam::::serviceRole:Reader", "display_name": "Reader", "description": "Reader role for example", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ] } ], "system_roles": [ { "crn": "crn:v1:bluemix:public:iam::::role:Viewer", "display_name": "Viewer", "description": "Viewer role for example", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ] } ] }{ "custom_roles": [ { "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" } ], "service_roles": [ { "crn": "crn:v1:bluemix:public:iam::::serviceRole:Reader", "display_name": "Reader", "description": "Reader role for example", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ] } ], "system_roles": [ { "crn": "crn:v1:bluemix:public:iam::::role:Viewer", "display_name": "Viewer", "description": "Viewer role for example", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ] } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "not_found", "message": "Not Found" } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "not_found", "message": "Not Found" } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Create a role
Creates a custom role for a specific service within the account. An account owner or a user assigned the Administrator role on the Role management service can create a custom role. Any number of actions for a single service can be mapped to the new role, but there must be at least one service-defined action to successfully create the new role.
Creates a custom role for a specific service within the account. An account owner or a user assigned the Administrator role on the Role management service can create a custom role. Any number of actions for a single service can be mapped to the new role, but there must be at least one service-defined action to successfully create the new role.
Creates a custom role for a specific service within the account. An account owner or a user assigned the Administrator role on the Role management service can create a custom role. Any number of actions for a single service can be mapped to the new role, but there must be at least one service-defined action to successfully create the new role.
Creates a custom role for a specific service within the account. An account owner or a user assigned the Administrator role on the Role management service can create a custom role. Any number of actions for a single service can be mapped to the new role, but there must be at least one service-defined action to successfully create the new role.
Creates a custom role for a specific service within the account. An account owner or a user assigned the Administrator role on the Role management service can create a custom role. Any number of actions for a single service can be mapped to the new role, but there must be at least one service-defined action to successfully create the new role.
POST /v2/roles
(iamPolicyManagement *IamPolicyManagementV1) CreateRole(createRoleOptions *CreateRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) CreateRoleWithContext(ctx context.Context, createRoleOptions *CreateRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error)
ServiceCall<CustomRole> createRole(CreateRoleOptions createRoleOptions)createRole(params)
create_role(
self,
display_name: str,
actions: List[str],
name: str,
account_id: str,
service_name: str,
*,
description: Optional[str] = None,
accept_language: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the CreateRoleOptions struct and set the fields to provide parameter values for the CreateRole method.
Use the CreateRoleOptions.Builder to create a CreateRoleOptions object that contains the parameter values for the createRole method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
A role to be created.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, contains only unique items, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
^[A-Z]{1}[A-Za-z0-9]{0,29}$Example:
DeveloperThe account GUID.
The service name.
Example:
iam-groupsThe description of the role.
Possible values: 1 ≤ length ≤ 250
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The CreateRole options.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The description of the role.
Possible values: 1 ≤ length ≤ 250
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
The createRole options.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The description of the role.
Possible values: 1 ≤ length ≤ 250
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
parameters
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:The account GUID.
The service name.
Examples:The description of the role.
Possible values: 1 ≤ length ≤ 250
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
parameters
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:The account GUID.
The service name.
Examples:The description of the role.
Possible values: 1 ≤ length ≤ 250
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
curl -X POST 'https://iam.cloud.ibm.com/v2/roles' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -d '{ "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "account_id": "ACCOUNT_ID", "service_name": "SERVICE_NAME", "actions":["ACTION_ID_1", "ACTION_ID_2"] }'
options := iamPolicyManagementService.NewCreateRoleOptions( "IAM Groups read access", []string{"iam-groups.groups.read"}, "ExampleRoleIAMGroups", exampleAccountID, exampleServiceName, ) customRole, response, err := iamPolicyManagementService.CreateRole(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(customRole, "", " ") exampleCustomRoleID = *customRole.ID fmt.Println(string(b))
CreateRoleOptions options = new CreateRoleOptions.Builder() .displayName("IAM Groups read access") .actions(Arrays.asList("iam-groups.groups.read")) .name("ExampleRoleIAMGroups") .accountId(exampleAccountId) .serviceName(EXAMPLE_SERVICE_NAME) .build(); Response<CustomRole> response = service.createRole(options).execute(); CustomRole customRole = response.getResult(); exampleCustomRoleId = customRole.getId(); System.out.println(customRole);
const params = { displayName: exampleCustomRoleDipslayName, actions: ['iam-groups.groups.read'], name: 'ExampleRoleIAMGroups', accountId: exampleAccountId, serviceName: exampleServiceName, }; try { const res = await iamPolicyManagementService.createRole(params); exampleCustomRoleId = res.result.id; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
custom_role = iam_policy_management_service.create_role( display_name='IAM Groups read access', actions=['iam-groups.groups.read'], name='ExampleRoleIAMGroups', account_id=example_account_id, service_name=example_service_name, ).get_result() global example_custom_role_id example_custom_role_id = custom_role["id"] print(json.dumps(custom_role, indent=2))
Response
An additional set of properties associated with a role.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, contains only unique items, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
^[A-Z]{1}[A-Za-z0-9]{0,29}$Example:
DeveloperThe account GUID.
The service name.
Example:
iam-groupsThe role ID. Composed of hexadecimal characters.
The description of the role.
Possible values: 1 ≤ length ≤ 250
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
Status Code
Role creation successful.
Role input is invalid.
The token that you provided is not valid.
You don't have access to create the role. You must be assigned the Administrator role on the Role management service.
The requested resource(s) cannot be formatted that uses the requested media type(s).
A role already exists with the same name or actions in the account. You can update that role or delete it and create a new one.
The request body sent was formatted that uses an unsupported media type.
Exceeded maximum roles quota.
Too many requests are within a time window.
{ "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" }{ "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "The role name conflicts with an existing system-defined role name. Choose a different name." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "The role name conflicts with an existing system-defined role name. Choose a different name." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to create the requested role. You must be assigned the Administrator role on the Role management service." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to create the requested role. You must be assigned the Administrator role on the Role management service." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_conflict_error", "message": "This role name is already in use. Update the existing one or change the role name to be unique.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "role": "ROLE" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_conflict_error", "message": "This role name is already in use. Update the existing one or change the role name to be unique.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "role": "ROLE" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "request_not_processed", "message": "Exceeded maximum roles quota (<limit>) for account <account_id>." } ], "status_code": 422 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "request_not_processed", "message": "Exceeded maximum roles quota (<limit>) for account <account_id>." } ], "status_code": 422 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Update a role
Update a custom role. A role administrator might want to update an existing role by updating the display name, description, or the actions that are mapped to the role. The name, account_id, and service_name can't be changed.
Update a custom role. A role administrator might want to update an existing role by updating the display name, description, or the actions that are mapped to the role. The name, account_id, and service_name can't be changed.
Update a custom role. A role administrator might want to update an existing role by updating the display name, description, or the actions that are mapped to the role. The name, account_id, and service_name can't be changed.
Update a custom role. A role administrator might want to update an existing role by updating the display name, description, or the actions that are mapped to the role. The name, account_id, and service_name can't be changed.
Update a custom role. A role administrator might want to update an existing role by updating the display name, description, or the actions that are mapped to the role. The name, account_id, and service_name can't be changed.
PUT /v2/roles/{role_id}(iamPolicyManagement *IamPolicyManagementV1) ReplaceRole(replaceRoleOptions *ReplaceRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ReplaceRoleWithContext(ctx context.Context, replaceRoleOptions *ReplaceRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error)
ServiceCall<CustomRole> replaceRole(ReplaceRoleOptions replaceRoleOptions)replaceRole(params)
replace_role(
self,
role_id: str,
if_match: str,
display_name: str,
actions: List[str],
*,
description: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ReplaceRoleOptions struct and set the fields to provide parameter values for the ReplaceRole method.
Use the ReplaceRoleOptions.Builder to create a ReplaceRoleOptions object that contains the parameter values for the replaceRole method.
Custom Headers
The revision number for updating a role and must match the ETag value of the existing role. The Etag can be retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header.
Path Parameters
The role ID.
Updated role content to be saved.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, contains only unique items, length ≥ 1
The description of the role.
Possible values: 1 ≤ length ≤ 250
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ReplaceRole options.
The role ID.
The revision number for updating a role and must match the ETag value of the existing role. The Etag can be retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The description of the role.
Possible values: 1 ≤ length ≤ 250
The replaceRole options.
The role ID.
The revision number for updating a role and must match the ETag value of the existing role. The Etag can be retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The description of the role.
Possible values: 1 ≤ length ≤ 250
parameters
The role ID.
The revision number for updating a role and must match the ETag value of the existing role. The Etag can be retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The description of the role.
Possible values: 1 ≤ length ≤ 250
parameters
The role ID.
The revision number for updating a role and must match the ETag value of the existing role. The Etag can be retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The description of the role.
Possible values: 1 ≤ length ≤ 250
curl -X PUT 'https://iam.cloud.ibm.com/v2/roles' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -H 'If-Match: $ETAG' -d '{ "display_name": "Example Role", "description": "Custom role for example", "actions":["ACTION_ID_1", "ACTION_ID_2"] }'
updatedRoleActions := []string{"iam-groups.groups.read", "iam-groups.groups.list"} options := iamPolicyManagementService.NewReplaceRoleOptions( exampleCustomRoleID, exampleCustomRoleETag, "ExampleRoleIAMGroups", updatedRoleActions, ) customRole, response, err := iamPolicyManagementService.ReplaceRole(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(customRole, "", " ") fmt.Println(string(b))
List<String> updatedRoleActions = Arrays.asList("iam-groups.groups.read", "iam-groups.groups.list"); ReplaceRoleOptions options = new ReplaceRoleOptions.Builder() .roleId(exampleCustomRoleId) .ifMatch(exampleCustomRoleEtag) .displayName("IAM Groups read access") .actions(updatedRoleActions) .build(); Response<CustomRole> response = service.replaceRole(options).execute(); CustomRole customRole = response.getResult(); System.out.println(customRole);
const updatedRoleActions = ['iam-groups.groups.read', 'iam-groups.groups.list']; const params = { roleId: exampleCustomRoleId, ifMatch: exampleCustomRoleEtag, displayName: exampleCustomRoleDipslayName, actions: updatedRoleActions, }; try { const res = await iamPolicyManagementService.replaceRole(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
updated_role_actions = ['iam-groups.groups.read', 'iam-groups.groups.list'] custom_role = iam_policy_management_service.replace_role( role_id=example_custom_role_id, if_match=example_custom_role_etag, actions=updated_role_actions, display_name='IAM Groups read access', ).get_result() print(json.dumps(custom_role, indent=2))
Response
An additional set of properties associated with a role.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, contains only unique items, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
^[A-Z]{1}[A-Za-z0-9]{0,29}$Example:
DeveloperThe account GUID.
The service name.
Example:
iam-groupsThe role ID. Composed of hexadecimal characters.
The description of the role.
Possible values: 1 ≤ length ≤ 250
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
Status Code
Role update successful.
Role input is invalid.
The token that you provided is not valid.
You do not have access to update the role.
Role was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
A role already exists with the same actions and account_id. You can update that role or delete it and create a new one.
The request body sent was formatted that uses an unsupported media type.
Too many requests are within a time window.
{ "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" }{ "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "In order to update an existing role, a rev value must be provided." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "In order to update an existing role, a rev value must be provided." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested role." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested role." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_not_found", "message": "Role with ID ROLE_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_not_found", "message": "Role with ID ROLE_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_conflict_error", "message": "The role wasn't updated.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "role": "ROLE" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_conflict_error", "message": "The role wasn't updated.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "role": "ROLE" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Retrieve a role by ID
Retrieve a role by providing a role ID.
Retrieve a role by providing a role ID.
Retrieve a role by providing a role ID.
Retrieve a role by providing a role ID.
Retrieve a role by providing a role ID.
GET /v2/roles/{role_id}(iamPolicyManagement *IamPolicyManagementV1) GetRole(getRoleOptions *GetRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) GetRoleWithContext(ctx context.Context, getRoleOptions *GetRoleOptions) (result *CustomRole, response *core.DetailedResponse, err error)
ServiceCall<CustomRole> getRole(GetRoleOptions getRoleOptions)getRole(params)
get_role(
self,
role_id: str,
**kwargs,
) -> DetailedResponseRequest
Instantiate the GetRoleOptions struct and set the fields to provide parameter values for the GetRole method.
Use the GetRoleOptions.Builder to create a GetRoleOptions object that contains the parameter values for the getRole method.
Path Parameters
The role ID.
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The GetRole options.
The role ID.
The getRole options.
The role ID.
parameters
The role ID.
parameters
The role ID.
curl -X GET 'https://iam.cloud.ibm.com/v2/roles/$ROLE_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewGetRoleOptions( exampleCustomRoleID, ) customRole, response, err := iamPolicyManagementService.GetRole(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(customRole, "", " ") exampleCustomRoleETag = response.Headers.Get("ETag") fmt.Println(string(b))
GetRoleOptions options = new GetRoleOptions.Builder() .roleId(exampleCustomRoleId) .build(); Response<CustomRole> response = service.getRole(options).execute(); CustomRole customRole = response.getResult(); exampleCustomRoleEtag = response.getHeaders().values("Etag").get(0); System.out.println(customRole);
const params = { roleId: exampleCustomRoleId, }; try { const res = await iamPolicyManagementService.getRole(params); exampleCustomRoleEtag = res.headers.etag; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
response = iam_policy_management_service.get_role(role_id=example_custom_role_id) custom_role = response.get_result() global example_custom_role_etag example_custom_role_etag = response.get_headers().get("Etag") print(json.dumps(custom_role, indent=2))
Response
An additional set of properties associated with a role.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, contains only unique items, length ≥ 1
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
^[A-Z]{1}[A-Za-z0-9]{0,29}$Example:
DeveloperThe account GUID.
The service name.
Example:
iam-groupsThe role ID. Composed of hexadecimal characters.
The description of the role.
Possible values: 1 ≤ length ≤ 250
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
An additional set of properties associated with a role.
The role ID. Composed of hexadecimal characters.
The display the name of the role that is shown in the console.
Possible values: 1 ≤ length ≤ 50
The description of the role.
Possible values: 1 ≤ length ≤ 250
The actions of the role. For more information, see IAM roles and actions.
Possible values: number of items ≥ 1, length ≥ 1
The role Cloud Resource Name (CRN). Example CRN: 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'.
The name of the role that is used in the CRN. This must be alphanumeric and capitalized.
Possible values: 1 ≤ length ≤ 30, Value must match regular expression
/^[A-Z]{1}[A-Za-z0-9]{0,29}$/Examples:Developer
The account GUID.
The service name.
Examples:iam-groups
The UTC timestamp when the role was created.
The IAM ID of the entity that created the role.
The UTC timestamp when the role was last modified.
The IAM ID of the entity that last modified the policy.
The href links back to the role.
Status Code
Role retrieval successful.
The token that you provided is not valid.
You do not have access to retrieve the role.
Role was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
Too many requests are within a time window.
{ "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" }{ "id": "12345678abcd1a2ba1b21234567890ab", "crn": "crn:v1:bluemix:public:iam-access-management::::customRole:Example", "name": "Example", "display_name": "Example Role", "description": "Custom role for example", "service_name": "SERVICE_NAME", "account_id": "ACCOUNT_ID", "actions": [ "ACTION_ID_1", "ACTION_ID_2" ], "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "USER_ID", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "USER_ID", "href": "https://iam.cloud.ibm.com/v2/roles/12345678abcd1a2ba1b21234567890ab" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to retrieve the requested role." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to retrieve the requested role." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_not_found", "message": "Role with ID ROLE_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_not_found", "message": "Role with ID ROLE_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Delete a role by ID
Delete a role by providing a role ID.
Delete a role by providing a role ID.
Delete a role by providing a role ID.
Delete a role by providing a role ID.
Delete a role by providing a role ID.
DELETE /v2/roles/{role_id}(iamPolicyManagement *IamPolicyManagementV1) DeleteRole(deleteRoleOptions *DeleteRoleOptions) (response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) DeleteRoleWithContext(ctx context.Context, deleteRoleOptions *DeleteRoleOptions) (response *core.DetailedResponse, err error)
ServiceCall<Void> deleteRole(DeleteRoleOptions deleteRoleOptions)deleteRole(params)
delete_role(
self,
role_id: str,
**kwargs,
) -> DetailedResponseRequest
Instantiate the DeleteRoleOptions struct and set the fields to provide parameter values for the DeleteRole method.
Use the DeleteRoleOptions.Builder to create a DeleteRoleOptions object that contains the parameter values for the deleteRole method.
Path Parameters
The role ID.
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The DeleteRole options.
The role ID.
The deleteRole options.
The role ID.
parameters
The role ID.
parameters
The role ID.
curl -X DELETE 'https://iam.cloud.ibm.com/v2/roles/$ROLE_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewDeleteRoleOptions( exampleCustomRoleID, ) response, err := iamPolicyManagementService.DeleteRole(options) if err != nil { panic(err) }
DeleteRoleOptions options = new DeleteRoleOptions.Builder() .roleId(exampleCustomRoleId) .build(); Response<Void> response = service.deleteRole(options).execute();
const params = { roleId: exampleCustomRoleId, }; try { await iamPolicyManagementService.deleteRole(params); } catch (err) { console.warn(err); }
response = iam_policy_management_service.delete_role(role_id=example_custom_role_id).get_result() print(json.dumps(response, indent=2))
Response
Status Code
Role deletion successful.
The token that you provided is not valid.
You do not have access to delete the role.
Role was not found.
Too many requests are within a time window.
{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to delete the requested role." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to delete the requested role." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_not_found", "message": "Role with ID ROLE_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "role_not_found", "message": "Role with ID ROLE_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Get policies by attributes
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
Get policies and filter by attributes. While managing policies, you might want to retrieve policies in the account and filter by attribute values. This can be done through query parameters. The following attributes are supported: account_id, iam_id, access_group_id, type, service_type, sort, format and state. account_id is a required query parameter. Only policies that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policies an empty array is returned.
GET /v2/policies
(iamPolicyManagement *IamPolicyManagementV1) ListV2Policies(listV2PoliciesOptions *ListV2PoliciesOptions) (result *V2PolicyCollection, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ListV2PoliciesWithContext(ctx context.Context, listV2PoliciesOptions *ListV2PoliciesOptions) (result *V2PolicyCollection, response *core.DetailedResponse, err error)
ServiceCall<V2PolicyCollection> listV2Policies(ListV2PoliciesOptions listV2PoliciesOptions)listV2Policies(params)
list_v2_policies(
self,
account_id: str,
*,
accept_language: Optional[str] = None,
iam_id: Optional[str] = None,
access_group_id: Optional[str] = None,
type: Optional[str] = None,
service_type: Optional[str] = None,
service_name: Optional[str] = None,
service_group_id: Optional[str] = None,
sort: Optional[str] = None,
format: Optional[str] = None,
state: Optional[str] = None,
limit: Optional[int] = None,
start: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ListV2PoliciesOptions struct and set the fields to provide parameter values for the ListV2Policies method.
Use the ListV2PoliciesOptions.Builder to create a ListV2PoliciesOptions object that contains the parameter values for the listV2Policies method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
Query Parameters
The account GUID in which the policies belong to.
Possible values: length ≥ 1
Optional IAM ID used to identify the subject.
Possible values: length ≥ 1
Optional access group id.
Possible values: length ≥ 1
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of service.
Possible values: length ≥ 1
Optional ID of service group.
Possible values: length ≥ 1
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field, for example, '-last_modified_at'. Note that last permit information is only included when 'format=include_last_permit', for example, "format=include_last_permit&sort=last_permit_at" Example fields that can be sorted on:
- 'type'
- 'href'
- 'created_at'
- 'created_by_id'
- 'last_modified_at'
- 'last_modified_by_id'
- 'state'
- 'last_permit_at'
- 'last_permit_frequency'
Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
^[-A-Za-z0-9+/]*$
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ListV2Policies options.
The account GUID in which the policies belong to.
Possible values: length ≥ 1
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Possible values: length ≥ 1
Optional access group id.
Possible values: length ≥ 1
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of service.
Possible values: length ≥ 1
Optional ID of service group.
Possible values: length ≥ 1
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field, for example, '-last_modified_at'. Note that last permit information is only included when 'format=include_last_permit', for example, "format=include_last_permit&sort=last_permit_at" Example fields that can be sorted on:
- 'type'
- 'href'
- 'created_at'
- 'created_by_id'
- 'last_modified_at'
- 'last_modified_by_id'
- 'state'
- 'last_permit_at'
- 'last_permit_frequency'.
Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Examples:10Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
The listV2Policies options.
The account GUID in which the policies belong to.
Possible values: length ≥ 1
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Possible values: length ≥ 1
Optional access group id.
Possible values: length ≥ 1
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of service.
Possible values: length ≥ 1
Optional ID of service group.
Possible values: length ≥ 1
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field, for example, '-last_modified_at'. Note that last permit information is only included when 'format=include_last_permit', for example, "format=include_last_permit&sort=last_permit_at" Example fields that can be sorted on:
- 'type'
- 'href'
- 'created_at'
- 'created_by_id'
- 'last_modified_at'
- 'last_modified_by_id'
- 'state'
- 'last_permit_at'
- 'last_permit_frequency'.
Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Examples:10Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
parameters
The account GUID in which the policies belong to.
Possible values: length ≥ 1
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Possible values: length ≥ 1
Optional access group id.
Possible values: length ≥ 1
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of service.
Possible values: length ≥ 1
Optional ID of service group.
Possible values: length ≥ 1
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field, for example, '-last_modified_at'. Note that last permit information is only included when 'format=include_last_permit', for example, "format=include_last_permit&sort=last_permit_at" Example fields that can be sorted on:
- 'type'
- 'href'
- 'created_at'
- 'created_by_id'
- 'last_modified_at'
- 'last_modified_by_id'
- 'state'
- 'last_permit_at'
- 'last_permit_frequency'.
Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
parameters
The account GUID in which the policies belong to.
Possible values: length ≥ 1
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultOptional IAM ID used to identify the subject.
Possible values: length ≥ 1
Optional access group id.
Possible values: length ≥ 1
Optional type of policy.
Allowable values: [
access,authorization]Optional type of service.
Allowable values: [
service,platform_service]Optional name of service.
Possible values: length ≥ 1
Optional ID of service group.
Possible values: length ≥ 1
Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field, for example, '-last_modified_at'. Note that last permit information is only included when 'format=include_last_permit', for example, "format=include_last_permit&sort=last_permit_at" Example fields that can be sorted on:
- 'type'
- 'href'
- 'created_at'
- 'created_by_id'
- 'last_modified_at'
- 'last_modified_by_id'
- 'state'
- 'last_permit_at'
- 'last_permit_frequency'.
Include additional data per policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]The state of the policy.
active- returns active policiesdeleted- returns non-active policies.
Allowable values: [
active,deleted]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
curl -X GET 'https://iam.cloud.ibm.com/v2/policies?account_id=$ACCOUNT_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewListV2PoliciesOptions( exampleAccountID, ) options.SetIamID(exampleUserID) options.SetFormat("include_last_permit") options.SetSort("-id") policyList, response, err := iamPolicyManagementService.ListV2Policies(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policyList, "", " ") fmt.Println(string(b))
ListV2PoliciesOptions options = new ListV2PoliciesOptions.Builder() .accountId(exampleAccountId) .iamId(EXAMPLE_USER_ID) .format("include_last_permit") .build(); Response<V2PolicyCollection> response = service.listV2Policies(options).execute(); V2PolicyCollection policyCollection = response.getResult(); System.out.println(policyCollection);
const params = { accountId: exampleAccountId, iamId: exampleUserId, format: 'include_last_permit', }; try { const res = await iamPolicyManagementService.listV2Policies(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
policy_list = iam_policy_management_service.list_v2_policies( account_id=example_account_id, iam_id=example_user_id, format='include_last_permit' ).get_result() print(json.dumps(policy_list, indent=2))
Response
A collection of policies.
List of policies.
Possible values: number of items ≥ 0
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
Details with href linking to the following page of requested collection.
Details with linking href to previous page of requested collection.
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- First
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- Next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- Previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
Possible values: number of items ≥ 0
- Policies
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- Template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
Possible values: number of items ≥ 0
- policies
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
Possible values: number of items ≥ 0
- policies
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
A collection of policies.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policies.
Possible values: number of items ≥ 0
- policies
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
Status Code
Policies retrieval successful.
The request you made is not valid.
The token that you provided is not valid.
The requested resource(s) cannot be formatted that uses the requested media type(s).
Too many requests are within a time window.
{ "policies": [ { "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" } ] }{ "policies": [ { "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "missing_required_query_parameter", "message": "'account_id' is a required query parameter" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "missing_required_query_parameter", "message": "'account_id' is a required query parameter" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Create a policy
Creates a policy to grant access between a subject and a resource. Currently, there is one type of a v2/policy: access. A policy administrator might want to create an access policy that grants access to a user, service-id, or an access group.
Access
To create an access policy, use "type": "access" in the body.
The supported subject attributes are iam_id and access_group_id.
Use the iam_id subject attribute to assign access to a user or service-id.
Use the access_group_id subject attribute to assign access to an access group.
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute.
In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator.
The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
You can use the following operators in the key and value pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals',
'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals',
'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals',
'dayOfWeekEquals', 'dayOfWeekAnyOf'
The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the pattern is "time-based-conditions:weekly".
For more information, see Time-based conditions operators and
Limiting access with time-based conditions.
If the subject is a locked service-id, the request will fail.
attribute-based: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR
the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy,
making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
Authorization policies are supported by services on a case by case basis.
Refer to service documentation to verify their support of authorization policies.
To create an authorization policy, use "type": "authorization" in the body.
The subject attributes must match the supported authorization subjects of the resource.
Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
The user must also have the same level of access or greater to the target resource in order to grant the role.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available.
For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. Currently, there is one type of a v2/policy: access. A policy administrator might want to create an access policy that grants access to a user, service-id, or an access group.
Access
To create an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals', 'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals', 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', 'dayOfWeekEquals', 'dayOfWeekAnyOf'
The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions operators](/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) and
[Limiting access with time-based conditions](/docs/account?topic=account-iam-time-based&interface=ui). If the subject is a locked service-id, the request will fail.
2. `attribute-based`: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
```json
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/_*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. Currently, there is one type of a v2/policy: access. A policy administrator might want to create an access policy that grants access to a user, service-id, or an access group.
Access
To create an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals', 'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals', 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', 'dayOfWeekEquals', 'dayOfWeekAnyOf'
The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions operators](/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) and
[Limiting access with time-based conditions](/docs/account?topic=account-iam-time-based&interface=ui). If the subject is a locked service-id, the request will fail.
2. `attribute-based`: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
```json
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/_*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. Currently, there is one type of a v2/policy: access. A policy administrator might want to create an access policy that grants access to a user, service-id, or an access group.
Access
To create an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals', 'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals', 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', 'dayOfWeekEquals', 'dayOfWeekAnyOf'
The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions operators](/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) and
[Limiting access with time-based conditions](/docs/account?topic=account-iam-time-based&interface=ui). If the subject is a locked service-id, the request will fail.
2. `attribute-based`: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
```json
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/_*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Creates a policy to grant access between a subject and a resource. Currently, there is one type of a v2/policy: access. A policy administrator might want to create an access policy that grants access to a user, service-id, or an access group.
Access
To create an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals', 'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals', 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', 'dayOfWeekEquals', 'dayOfWeekAnyOf'
The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions operators](/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) and
[Limiting access with time-based conditions](/docs/account?topic=account-iam-time-based&interface=ui). If the subject is a locked service-id, the request will fail.
2. `attribute-based`: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
```json
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
Authorization policies are supported by services on a case by case basis. Refer to service documentation to verify their support of authorization policies. To create an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
POST /v2/policies
(iamPolicyManagement *IamPolicyManagementV1) CreateV2Policy(createV2PolicyOptions *CreateV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) CreateV2PolicyWithContext(ctx context.Context, createV2PolicyOptions *CreateV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error)
ServiceCall<V2Policy> createV2Policy(CreateV2PolicyOptions createV2PolicyOptions)createV2Policy(params)
create_v2_policy(
self,
control: 'Control',
type: str,
*,
description: Optional[str] = None,
subject: Optional['V2PolicySubject'] = None,
resource: Optional['V2PolicyResource'] = None,
pattern: Optional[str] = None,
rule: Optional['V2PolicyRule'] = None,
accept_language: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the CreateV2PolicyOptions struct and set the fields to provide parameter values for the CreateV2Policy method.
Use the CreateV2PolicyOptions.Builder to create a CreateV2PolicyOptions object that contains the parameter values for the createV2Policy method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
A policy to be created.
Specifies the type of access that is granted by the policy.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
^.*$The subject attributes for whom the policy grants access.
The resource attributes to which the policy grants access.
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
^[a-z:-]*$Additional access conditions associated with the policy.
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The CreateV2Policy options.
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
The createV2Policy options.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
parameters
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
parameters
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
default
curl -X POST 'https://iam.cloud.ibm.com/v2/policies' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -d '{ "type": "access", "description": "Editor role for SERVICE_NAME\'s RESOURCE_NAME", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Editor" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "$ACCOUNT_ID" }, { "key": "serviceName", "operator": "stringEquals", "value": "$SERVICE_NAME" }, { "key": "resource", "operator": "stringEquals", "value": "$RESOURCE_NAME" } ] }, "rule" :{ "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"] }, "pattern": "time-based-conditions:weekly:all-day" }'
subjectAttribute := &iampolicymanagementv1.V2PolicySubjectAttribute{ Key: core.StringPtr("iam_id"), Operator: core.StringPtr("stringEquals"), Value: &exampleUserID, } policySubject := &iampolicymanagementv1.V2PolicySubject{ Attributes: []iampolicymanagementv1.V2PolicySubjectAttribute{*subjectAttribute}, } policyRole := &iampolicymanagementv1.Roles{ RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Viewer"), } v2PolicyGrant := &iampolicymanagementv1.Grant{ Roles: []iampolicymanagementv1.Roles{*policyRole}, } v2PolicyControl := &iampolicymanagementv1.Control{ Grant: v2PolicyGrant, } accountIDResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("accountId"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr(exampleAccountID), } serviceNameResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("serviceType"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr("service"), } policyResourceTag := &iampolicymanagementv1.V2PolicyResourceTag{ Key: core.StringPtr("project"), Value: core.StringPtr("prototype"), Operator: core.StringPtr("stringEquals"), } policyResource := &iampolicymanagementv1.V2PolicyResource{ Attributes: []iampolicymanagementv1.V2PolicyResourceAttribute{ *accountIDResourceAttribute, *serviceNameResourceAttribute}, Tags: []iampolicymanagementv1.V2PolicyResourceTag{*policyResourceTag}, } weeklyConditionAttribute := &iampolicymanagementv1.NestedCondition{ Key: core.StringPtr("{{environment.attributes.day_of_week}}"), Operator: core.StringPtr("dayOfWeekAnyOf"), Value: []string{"1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"}, } startConditionAttribute := &iampolicymanagementv1.NestedCondition{ Key: core.StringPtr("{{environment.attributes.current_time}}"), Operator: core.StringPtr("timeGreaterThanOrEquals"), Value: core.StringPtr("09:00:00+00:00"), } endConditionAttribute := &iampolicymanagementv1.NestedCondition{ Key: core.StringPtr("{{environment.attributes.current_time}}"), Operator: core.StringPtr("timeLessThanOrEquals"), Value: core.StringPtr("17:00:00+00:00"), } policyRule := &iampolicymanagementv1.V2PolicyRule{ Operator: core.StringPtr("and"), Conditions: []iampolicymanagementv1.NestedConditionIntf{ weeklyConditionAttribute, startConditionAttribute, endConditionAttribute}, } options := iamPolicyManagementService.NewCreateV2PolicyOptions( v2PolicyControl, "access", ) options.SetSubject(policySubject) options.SetResource(policyResource) options.SetRule(policyRule) options.SetPattern(*core.StringPtr("time-based-conditions:weekly:custom-hours")) policy, response, err := iamPolicyManagementService.CreateV2Policy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") examplePolicyID = *policy.ID fmt.Println(string(b))
V2PolicySubjectAttribute subjectAttribute = new V2PolicySubjectAttribute.Builder() .key("iam_id") .value(EXAMPLE_USER_ID) .operator("stringEquals") .build(); V2PolicySubject policySubject = new V2PolicySubject.Builder() .addAttributes(subjectAttribute) .build(); V2PolicyResourceAttribute accountIdResourceAttribute = new V2PolicyResourceAttribute.Builder() .key("accountId") .value(exampleAccountId) .operator("stringEquals") .build(); V2PolicyResourceAttribute serviceNameResourceAttribute = new V2PolicyResourceAttribute.Builder() .key("serviceType") .value("service") .operator("stringEquals") .build(); V2PolicyResourceTag policyResourceTag = new V2PolicyResourceTag.Builder() .key("project") .value("prototype") .operator("stringEquals") .build(); V2PolicyResource policyResource = new V2PolicyResource.Builder() .addAttributes(accountIdResourceAttribute) .addAttributes(serviceNameResourceAttribute) .addTags(policyResourceTag) .build(); Roles policyRoles = new Roles.Builder() .roleId("crn:v1:bluemix:public:iam::::role:Viewer") .build(); Grant policyGrant = new Grant.Builder() .roles(Arrays.asList(policyRoles)) .build(); Control control = new Control.Builder() .grant(policyGrant) .build(); NestedConditionRuleAttribute weeklyConditionAttribute = new NestedConditionRuleAttribute.Builder() .key("{{environment.attributes.day_of_week}}") .value(new ArrayList<String>(Arrays.asList("1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"))) .operator("dayOfWeekAnyOf") .build(); NestedConditionRuleAttribute startConditionAttribute = new NestedConditionRuleAttribute.Builder() .key("{{environment.attributes.current_time}}") .value("09:00:00+00:00") .operator("timeGreaterThanOrEquals") .build(); NestedConditionRuleAttribute endConditionAttribute = new NestedConditionRuleAttribute.Builder() .key("{{environment.attributes.current_time}}") .value("17:00:00+00:00") .operator("timeLessThanOrEquals") .build(); V2PolicyRuleRuleWithNestedConditions policyRule = new V2PolicyRuleRuleWithNestedConditions.Builder() .operator("and") .conditions(new ArrayList<NestedCondition>(Arrays.asList(weeklyConditionAttribute, startConditionAttribute, endConditionAttribute))) .build(); CreateV2PolicyOptions options = new CreateV2PolicyOptions.Builder() .type("access") .subject(policySubject) .control(control) .resource(policyResource) .rule(policyRule) .pattern("time-based-conditions:weekly:custom-hours") .build(); Response<V2Policy> response = service.createV2Policy(options).execute(); V2Policy policy = response.getResult(); exampleV2PolicyId = policy.getId(); System.out.println(policy);
const policySubject = { attributes: [ { key: 'iam_id', operator: 'stringEquals', value: exampleUserId, }, ], }; const policyResourceAccountAttribute = { key: 'accountId', value: exampleAccountId, operator: 'stringEquals', }; const policyResourceServiceAttribute = { key: 'serviceType', operator: 'stringEquals', value: 'service', }; const policyResource = { attributes: [policyResourceAccountAttribute, policyResourceServiceAttribute] }; const policyControl = { grant: { roles: [{ role_id: 'crn:v1:bluemix:public:iam::::role:Viewer', }], } }; const policyRule = { operator: 'and', conditions: [ { key: '{{environment.attributes.day_of_week}}', operator: 'dayOfWeekAnyOf', value: ['1+00:00', '2+00:00', '3+00:00', '4+00:00', '5+00:00'], }, { key: '{{environment.attributes.current_time}}', operator: 'timeGreaterThanOrEquals', value: '09:00:00+00:00', }, { key: '{{environment.attributes.current_time}}', operator: 'timeLessThanOrEquals', value: '17:00:00+00:00', }, ], } const policyPattern = 'time-based-conditions:weekly:custom-hours' const params = { type: 'access', subject: policySubject, control: policyControl, resource: policyResource, rule: policyRule, pattern: policyPattern, }; try { const res = await iamPolicyManagementService.createV2Policy(params); examplePolicyId = res.result.id; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
policy_subject = V2PolicySubject( attributes=[V2PolicySubjectAttribute(key='iam_id', value=example_user_id, operator='stringEquals')] ) policy_role = PolicyRole(role_id='crn:v1:bluemix:public:iam::::role:Viewer') account_id_resource_attribute = V2PolicyResourceAttribute( key='accountId', value=example_account_id, operator='stringEquals' ) service_name_resource_attribute = V2PolicyResourceAttribute( key='serviceType', value='service', operator='stringEquals' ) policy_resource_tag = V2PolicyResourceTag(key='project', value='prototype', operator='stringEquals') policy_resource = V2PolicyResource( attributes=[account_id_resource_attribute, service_name_resource_attribute], tags=[policy_resource_tag] ) policy_control = Control(grant=Grant(roles=[policy_role])) policy_rule = V2PolicyRuleRuleWithNestedConditions( operator='and', conditions=[ RuleAttribute( key='{{environment.attributes.day_of_week}}', operator='dayOfWeekAnyOf', value=['1+00:00', '2+00:00', '3+00:00', '4+00:00', '5+00:00'], ), RuleAttribute( key='{{environment.attributes.current_time}}', operator='timeGreaterThanOrEquals', value='09:00:00+00:00', ), RuleAttribute( key='{{environment.attributes.current_time}}', operator='timeLessThanOrEquals', value='17:00:00+00:00', ), ], ) policy_pattern = 'time-based-conditions:weekly:custom-hours' policy = iam_policy_management_service.create_v2_policy( type='access', subject=policy_subject, control=policy_control, resource=policy_resource, rule=policy_rule, pattern=policy_pattern, ).get_result() global example_policy_id example_policy_id = policy['id'] print(json.dumps(policy, indent=2))
Response
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]The policy ID.
The href URL that links to the policies API by policy ID.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
^.*$The subject attributes for whom the policy grants access.
The resource attributes to which the policy grants access.
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
^[a-z:-]*$Additional access conditions associated with the policy.
The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
Status Code
Policy creation successful.
Policy input is invalid.
The token that you provided is not valid.
You do not have access to create the policy.
The requested resource(s) cannot be formatted that uses the requested media type(s).
A policy already exists for the given subject and resource. You can update that policy or delete it and create a new one.
The request body sent was formatted that uses an unsupported media type.
Exceeded maximum policies quota.
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Invalid body format. Check the input parameters." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Invalid body format. Check the input parameters." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to create the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to create the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to create policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to create policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "request_not_processed", "message": "Exceeded maximum policies quota (4020) for account 100abcde100a41abc100aza678abc0zz." } ], "status_code": 422 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "request_not_processed", "message": "Exceeded maximum policies quota (4020) for account 100abcde100a41abc100aza678abc0zz." } ], "status_code": 422 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Update a policy
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy.
Access
To update an access policy, use "type": "access" in the body.
The supported subject attributes are iam_id and access_group_id.
Use the iam_id subject attribute to assign access to a user or service-id.
Use the access_group_id subject attribute to assign access to an access group.
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute.
In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator.
The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
You can use the following operators in the key and value pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals',
'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals',
'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals',
'dayOfWeekEquals', 'dayOfWeekAnyOf'
The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the pattern is "time-based-conditions:weekly".
For more information, see Time-based conditions operators and
Limiting access with time-based conditions.
If the subject is a locked service-id, the request will fail.
attribute-based: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR
the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy,
making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
To update an authorization policy, use "type": "authorization" in the body.
The subject attributes must match the supported authorization subjects of the resource.
Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId
Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions.
The user must also have the same level of access or greater to the target resource in order to grant the role.
Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation.
Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available.
For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy.
Access
To update an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals',
'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals',
'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals',
'dayOfWeekEquals', 'dayOfWeekAnyOf'
``` The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the pattern is "time-based-conditions:weekly". For more information, see Time-based conditions operators and
Limiting access with time-based conditions. If the subject is a locked service-id, the request will fail.
attribute-based: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/_*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy.
Access
To update an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals',
'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals',
'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals',
'dayOfWeekEquals', 'dayOfWeekAnyOf'
``` The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the pattern is "time-based-conditions:weekly". For more information, see Time-based conditions operators and
Limiting access with time-based conditions. If the subject is a locked service-id, the request will fail.
attribute-based: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/_*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy.
Access
To update an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals',
'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals',
'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals',
'dayOfWeekEquals', 'dayOfWeekAnyOf'
``` The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the pattern is "time-based-conditions:weekly". For more information, see Time-based conditions operators and
Limiting access with time-based conditions. If the subject is a locked service-id, the request will fail.
attribute-based: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/_*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
Update a policy to grant access between a subject and a resource. A policy administrator might want to update an existing policy.
Access
To update an access policy, use "type": "access" in the body. The supported subject attributes are iam_id and access_group_id. Use the iam_id subject attribute to assign access to a user or service-id. Use the access_group_id subject attribute to assign access to an access group. Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. The policy resource must include either the serviceType, serviceName, resourceGroupId or service_group_id attribute and the accountId attribute. In the rule field, you can specify a single condition by using key, value, and condition operator, or a set of conditions with a combination operator. The possible combination operators are and and or.
Currently, we support two types of patterns:
time-based: Used to specify a time-based restriction
Combine conditions to specify a time-based restriction (e.g., access only during business hours, during the Monday-Friday work week). For example, a policy can grant access Monday-Friday, 9:00am-5:00pm using the following rule:
"rule": {
"operator": "and",
"conditions": [{
"key": "{{environment.attributes.day_of_week}}",
"operator": "dayOfWeekAnyOf",
"value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeGreaterThanOrEquals",
"value": "09:00:00+00:00"
},
"key": "{{environment.attributes.current_time}}",
"operator": "timeLessThanOrEquals",
"value": "17:00:00+00:00"
}]
}
``` You can use the following operators in the **`key`** and **`value`** pair:
'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan', 'timeGreaterThanOrEquals',
'dateLessThan', 'dateLessThanOrEquals', 'dateGreaterThan', 'dateGreaterThanOrEquals',
'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals',
'dayOfWeekEquals', 'dayOfWeekAnyOf'
``` The pattern field that matches the rule is required when rule is provided. For the business hour rule example above, the pattern is "time-based-conditions:weekly". For more information, see Time-based conditions operators and
Limiting access with time-based conditions. If the subject is a locked service-id, the request will fail.
attribute-based: Used to specify a combination of OR/AND based conditions applied on resource attributes.
Combine conditions to specify an attribute-based condition using AND/OR-based operators.
For example, a policy can grant access based on multiple conditions applied on the resource attributes below:
"pattern": "attribute-based-condition:resource:literal-and-wildcard"
"rule": {
"operator": "or",
"conditions": [
{
"operator": "and",
"conditions": [
{
"key": "{{resource.attributes.prefix}}",
"operator": "stringEquals",
"value": "home/test"
},
{
"key": "{{environment.attributes.delimiter}}",
"operator": "stringEquals",
"value": "/"
}
]
},
{
"key": "{{resource.attributes.path}}",
"operator": "stringMatch",
"value": "home/David/*"
}
]
}
In addition to satisfying the resources section, the policy grants permission only if either the path begins with home/David/ OR the prefix is home/test and the delimiter is /. This mechanism helps you consolidate multiple policies in to a single policy, making policies easier to administer and stay within the policy limit for an account. View the list of operators that can be used in the condition here.
Authorization
To update an authorization policy, use "type": "authorization" in the body. The subject attributes must match the supported authorization subjects of the resource. Multiple subject attributes might be provided. The following attributes are supported:
serviceName, serviceInstance, region, resourceType, resource, accountId, resourceGroupId Assign roles that are supported by the service or platform roles. For more information, see IAM roles and actions. The user must also have the same level of access or greater to the target resource in order to grant the role. Use only the resource attributes supported by the service. To view a service's or the platform's supported attributes, check the documentation. Both the policy subject and the policy resource must include the accountId attributes. The policy subject must include either serviceName or resourceGroupId (or both) attributes.
Attribute Operators
Currently, only the stringEquals, stringMatch, and stringEquals operators are available. For more information, see Assigning access by using wildcard policies.
Attribute Validations
Policy attribute values must be between 1 and 1,000 characters in length. If location related attributes like geography, country, metro, region, satellite, and locationvalues are supported by the service, they are validated against Global Catalog locations.
PUT /v2/policies/{id}(iamPolicyManagement *IamPolicyManagementV1) ReplaceV2Policy(replaceV2PolicyOptions *ReplaceV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ReplaceV2PolicyWithContext(ctx context.Context, replaceV2PolicyOptions *ReplaceV2PolicyOptions) (result *V2Policy, response *core.DetailedResponse, err error)
ServiceCall<V2Policy> replaceV2Policy(ReplaceV2PolicyOptions replaceV2PolicyOptions)replaceV2Policy(params)
replace_v2_policy(
self,
id: str,
if_match: str,
control: 'Control',
type: str,
*,
description: Optional[str] = None,
subject: Optional['V2PolicySubject'] = None,
resource: Optional['V2PolicyResource'] = None,
pattern: Optional[str] = None,
rule: Optional['V2PolicyRule'] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ReplaceV2PolicyOptions struct and set the fields to provide parameter values for the ReplaceV2Policy method.
Use the ReplaceV2PolicyOptions.Builder to create a ReplaceV2PolicyOptions object that contains the parameter values for the replaceV2Policy method.
Custom Headers
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v2/policies/{id} API and looking at the ETag response header.
Possible values: length ≥ 1
Path Parameters
The policy ID.
Possible values: length ≥ 1
Updated policy content to be saved.
Specifies the type of access that is granted by the policy.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
^.*$The subject attributes for whom the policy grants access.
The resource attributes to which the policy grants access.
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
^[a-z:-]*$Additional access conditions associated with the policy.
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ReplaceV2Policy options.
The policy ID.
Possible values: length ≥ 1
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v2/policies/{id} API and looking at the ETag response header.
Possible values: length ≥ 1
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The replaceV2Policy options.
The policy ID.
Possible values: length ≥ 1
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v2/policies/{id} API and looking at the ETag response header.
Possible values: length ≥ 1
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
parameters
The policy ID.
Possible values: length ≥ 1
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v2/policies/{id} API and looking at the ETag response header.
Possible values: length ≥ 1
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
parameters
The policy ID.
Possible values: length ≥ 1
The revision number for updating a policy and must match the ETag value of the existing policy. The Etag can be retrieved using the GET /v2/policies/{id} API and looking at the ETag response header.
Possible values: length ≥ 1
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The policy type; either 'access' or 'authorization'.
Allowable values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Allowable values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Allowable values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
curl -X PUT 'https://iam.cloud.ibm.com/v2/policies' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json' -H 'If-Match: $ETAG' -d '{ "type": "access", "description": "Viewer role for for all instances of SERVICE_NAME in the account.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "$ACCOUNT_ID" }, { "key": "serviceName", "operator": "stringEquals", "value": "$SERVICE_NAME" } ] }, "rule": { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"] }, "pattern": "time-based-conditions:weekly:all-day" }'
subjectAttribute := &iampolicymanagementv1.V2PolicySubjectAttribute{ Key: core.StringPtr("iam_id"), Operator: core.StringPtr("stringEquals"), Value: &exampleUserID, } policySubject := &iampolicymanagementv1.V2PolicySubject{ Attributes: []iampolicymanagementv1.V2PolicySubjectAttribute{*subjectAttribute}, } updatedPolicyRole := &iampolicymanagementv1.Roles{ RoleID: core.StringPtr("crn:v1:bluemix:public:iam::::role:Editor"), } v2PolicyGrant := &iampolicymanagementv1.Grant{ Roles: []iampolicymanagementv1.Roles{*updatedPolicyRole}, } v2PolicyControl := &iampolicymanagementv1.Control{ Grant: v2PolicyGrant, } accountIDResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("accountId"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr(exampleAccountID), } serviceNameResourceAttribute := &iampolicymanagementv1.V2PolicyResourceAttribute{ Key: core.StringPtr("serviceType"), Operator: core.StringPtr("stringEquals"), Value: core.StringPtr("service"), } policyResource := &iampolicymanagementv1.V2PolicyResource{ Attributes: []iampolicymanagementv1.V2PolicyResourceAttribute{ *accountIDResourceAttribute, *serviceNameResourceAttribute}, } options := iamPolicyManagementService.NewReplaceV2PolicyOptions( examplePolicyID, examplePolicyETag, v2PolicyControl, "access", ) weeklyConditionAttribute := &iampolicymanagementv1.NestedCondition{ Key: core.StringPtr("{{environment.attributes.day_of_week}}"), Operator: core.StringPtr("dayOfWeekAnyOf"), Value: []string{"1+00:00", "2+00:00", "3+00:00", "4+00:00"}, } startConditionAttribute := &iampolicymanagementv1.NestedCondition{ Key: core.StringPtr("{{environment.attributes.current_time}}"), Operator: core.StringPtr("timeGreaterThanOrEquals"), Value: core.StringPtr("09:00:00+00:00"), } endConditionAttribute := &iampolicymanagementv1.NestedCondition{ Key: core.StringPtr("{{environment.attributes.current_time}}"), Operator: core.StringPtr("timeLessThanOrEquals"), Value: core.StringPtr("17:00:00+00:00"), } policyRule := &iampolicymanagementv1.V2PolicyRule{ Operator: core.StringPtr("and"), Conditions: []iampolicymanagementv1.NestedConditionIntf{ weeklyConditionAttribute, startConditionAttribute, endConditionAttribute}, } options.SetRule(policyRule) options.SetPattern(*core.StringPtr("time-based-conditions:weekly:custom-hours")) options.SetSubject(policySubject) options.SetResource(policyResource) policy, response, err := iamPolicyManagementService.ReplaceV2Policy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") fmt.Println(string(b))
V2PolicySubjectAttribute subjectAttribute = new V2PolicySubjectAttribute.Builder() .key("iam_id") .value(EXAMPLE_USER_ID) .operator("stringEquals") .build(); V2PolicySubject policySubject = new V2PolicySubject.Builder() .addAttributes(subjectAttribute) .build(); V2PolicyResourceAttribute accountIdResourceAttribute = new V2PolicyResourceAttribute.Builder() .key("accountId") .value(exampleAccountId) .operator("stringEquals") .build(); V2PolicyResourceAttribute serviceNameResourceAttribute = new V2PolicyResourceAttribute.Builder() .key("serviceType") .value("service") .operator("stringEquals") .build(); V2PolicyResourceTag policyResourceTag = new V2PolicyResourceTag.Builder() .key("project") .value("prototype") .operator("stringEquals") .build(); V2PolicyResource policyResource = new V2PolicyResource.Builder() .addAttributes(accountIdResourceAttribute) .addAttributes(serviceNameResourceAttribute) .addTags(policyResourceTag) .build(); Roles updatedPolicyRole = new Roles.Builder() .roleId("crn:v1:bluemix:public:iam::::role:Editor") .build(); Grant policyGrant = new Grant.Builder() .roles(Arrays.asList(updatedPolicyRole)) .build(); Control policyControl = new Control.Builder() .grant(policyGrant) .build(); NestedConditionRuleAttribute weeklyConditionAttribute = new NestedConditionRuleAttribute.Builder() .key("{{environment.attributes.day_of_week}}") .value(new ArrayList<String>(Arrays.asList("1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"))) .operator("dayOfWeekAnyOf") .build(); NestedConditionRuleAttribute startConditionAttribute = new NestedConditionRuleAttribute.Builder() .key("{{environment.attributes.current_time}}") .value("09:00:00+00:00") .operator("timeGreaterThanOrEquals") .build(); NestedConditionRuleAttribute endConditionAttribute = new NestedConditionRuleAttribute.Builder() .key("{{environment.attributes.current_time}}") .value("17:00:00+00:00") .operator("timeLessThanOrEquals") .build(); V2PolicyRuleRuleWithNestedConditions policyRule = new V2PolicyRuleRuleWithNestedConditions.Builder() .operator("and") .conditions(new ArrayList<NestedCondition>(Arrays.asList(weeklyConditionAttribute, startConditionAttribute, endConditionAttribute))) .build(); ReplaceV2PolicyOptions options = new ReplaceV2PolicyOptions.Builder() .type("access") .id(exampleV2PolicyId) .ifMatch(exampleV2PolicyEtag) .subject(policySubject) .control(policyControl) .resource(policyResource) .rule(policyRule) .pattern("time-based-conditions:weekly:custom-hours") .build(); Response<V2Policy> response = service.replaceV2Policy(options).execute(); V2Policy policy = response.getResult(); exampleV2PolicyEtag = response.getHeaders().values("Etag").get(0); System.out.println(policy);
const policySubject = { attributes: [ { key: 'iam_id', operator: 'stringEquals', value: exampleUserId, }, ], }; const policyResourceAccountAttribute = { key: 'accountId', value: exampleAccountId, operator: 'stringEquals', }; const policyResourceServiceAttribute = { key: 'serviceType', operator: 'stringEquals', value: 'service', }; const policyResource = { attributes: [policyResourceAccountAttribute, policyResourceServiceAttribute] }; const updatedPolicyControl = { grant: { roles: [{ role_id: 'crn:v1:bluemix:public:iam::::role:Editor', }], } }; const policyRule = { operator: 'and', conditions: [ { key: '{{environment.attributes.day_of_week}}', operator: 'dayOfWeekAnyOf', value: ['1+00:00', '2+00:00', '3+00:00', '4+00:00', '5+00:00'], }, { key: '{{environment.attributes.current_time}}', operator: 'timeGreaterThanOrEquals', value: '09:00:00+00:00', }, { key: '{{environment.attributes.current_time}}', operator: 'timeLessThanOrEquals', value: '17:00:00+00:00', }, ], } const policyPattern = 'time-based-conditions:weekly:custom-hours' const params = { type: 'access', id: examplePolicyId, ifMatch: examplePolicyETag, subject: policySubject, control: updatedPolicyControl, resource: policyResource, rule: policyRule, pattern: policyPattern, }; try { const res = await iamPolicyManagementService.replaceV2Policy(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
policy_subject = V2PolicySubject( attributes=[V2PolicySubjectAttribute(key='iam_id', value=example_user_id, operator='stringEquals')] ) updated_policy_role = PolicyRole(role_id='crn:v1:bluemix:public:iam::::role:Editor') account_id_resource_attribute = V2PolicyResourceAttribute( key='accountId', value=example_account_id, operator='stringEquals' ) service_name_resource_attribute = V2PolicyResourceAttribute( key='serviceType', value='service', operator='stringEquals' ) policy_resource_tag = V2PolicyResourceTag(key='project', value='prototype', operator='stringEquals') policy_resource = PolicyResource( attributes=[account_id_resource_attribute, service_name_resource_attribute], tags=[policy_resource_tag] ) policy_control = Control(grant=Grant(roles=[updated_policy_role])) policy_rule = V2PolicyRuleRuleWithNestedConditions( operator='and', conditions=[ RuleAttribute( key='{{environment.attributes.day_of_week}}', operator='dayOfWeekAnyOf', value=['1+00:00', '2+00:00', '3+00:00', '4+00:00', '5+00:00'], ), RuleAttribute( key='{{environment.attributes.current_time}}', operator='timeGreaterThanOrEquals', value='09:00:00+00:00', ), RuleAttribute( key='{{environment.attributes.current_time}}', operator='timeLessThanOrEquals', value='17:00:00+00:00', ), ], ) policy_pattern = 'time-based-conditions:weekly:custom-hours' response = iam_policy_management_service.replace_v2_policy( type='access', id=example_policy_id, if_match=example_policy_etag, subject=policy_subject, control=policy_control, resource=policy_resource, rule=policy_rule, pattern=policy_pattern, ) policy = response.get_result() print(json.dumps(policy, indent=2))
Response
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]The policy ID.
The href URL that links to the policies API by policy ID.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
^.*$The subject attributes for whom the policy grants access.
The resource attributes to which the policy grants access.
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
^[a-z:-]*$Additional access conditions associated with the policy.
The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
Status Code
Policy update successful.
Policy input is invalid.
The token that you provided is not valid.
You do not have access to update the policy.
The policy was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
A policy already exists for the given subject and resource. You can update that policy or delete it and create a new one.
The request body sent was formatted that uses an unsupported media type.
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours, except Friday.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours, except Friday.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "A policy's type cannot be updated. Create a new policy and delete the existing one." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "A policy's type cannot be updated. Create a new policy and delete the existing one." } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to update the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to update policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_conflict_error", "message": "Failed to update policy.", "details": { "conflicts_with": { "etag": "1-847833cec3bf3f3c3231d8f9492febac", "policy": "POLICY" } }, "status_code": 409 } ] }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unsupported_content_type", "message": "The supported media type for this API is 'application/json'." } ], "status_code": 415 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Retrieve a policy by ID
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
Retrieve a policy by providing a policy ID.
GET /v2/policies/{id}(iamPolicyManagement *IamPolicyManagementV1) GetV2Policy(getV2PolicyOptions *GetV2PolicyOptions) (result *V2PolicyTemplateMetaData, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) GetV2PolicyWithContext(ctx context.Context, getV2PolicyOptions *GetV2PolicyOptions) (result *V2PolicyTemplateMetaData, response *core.DetailedResponse, err error)
ServiceCall<V2PolicyTemplateMetaData> getV2Policy(GetV2PolicyOptions getV2PolicyOptions)getV2Policy(params)
get_v2_policy(
self,
id: str,
*,
format: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the GetV2PolicyOptions struct and set the fields to provide parameter values for the GetV2Policy method.
Use the GetV2PolicyOptions.Builder to create a GetV2PolicyOptions object that contains the parameter values for the getV2Policy method.
Path Parameters
The policy ID.
Possible values: length ≥ 1
Query Parameters
Include additional data for policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields
Allowable values: [
include_last_permit,display]
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The GetV2Policy options.
The policy ID.
Possible values: length ≥ 1
Include additional data for policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]
The getV2Policy options.
The policy ID.
Possible values: length ≥ 1
Include additional data for policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]
parameters
The policy ID.
Possible values: length ≥ 1
Include additional data for policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]
parameters
The policy ID.
Possible values: length ≥ 1
Include additional data for policy returned
include_last_permit- returns details of when the policy last granted a permit decision and the number of times it has done sodisplay- returns the list of all actions included in each of the policy roles and translations for all relevant fields.
Allowable values: [
include_last_permit,display]
curl -X GET 'https://iam.cloud.ibm.com/v2/policies/$POLICY_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewGetV2PolicyOptions( examplePolicyID, ) policy, response, err := iamPolicyManagementService.GetV2Policy(options) if err != nil { panic(err) } b, _ := json.MarshalIndent(policy, "", " ") examplePolicyETag = response.GetHeaders().Get("ETag") fmt.Println(string(b))
GetV2PolicyOptions options = new GetV2PolicyOptions.Builder() .id(exampleV2PolicyId) .build(); Response<V2PolicyTemplateMetaData> response = service.getV2Policy(options).execute(); V2PolicyTemplateMetaData policy = response.getResult(); exampleV2PolicyEtag = response.getHeaders().values("Etag").get(0); System.out.println(policy); GetV2PolicyOptions options = new GetV2PolicyOptions.Builder() .id(exampleAssignmentPolicyId) .build(); Response<V2PolicyTemplateMetaData> response = service.getV2Policy(options).execute(); V2PolicyTemplateMetaData policy = response.getResult(); System.out.println(policy.getTemplate());
const params = { id: examplePolicyId, }; try { const res = await iamPolicyManagementService.getV2Policy(params); examplePolicyETag = res.headers.etag; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) } const params = { id: exampleAssignmentPolicyId, }; try { const res = await iamPolicyManagementService.getV2Policy(params); examplePolicyETag = res.headers.etag; console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err) }
response = iam_policy_management_service.get_v2_policy(id=example_policy_id) policy = response.get_result() global example_policy_etag example_policy_etag = response.get_headers().get("Etag") print(json.dumps(policy, indent=2))
Response
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]The policy ID.
The href URL that links to the policies API by policy ID.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
^.*$The subject attributes for whom the policy grants access.
The resource attributes to which the policy grants access.
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
^[a-z:-]*$Additional access conditions associated with the policy.
The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- Template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
The core set of properties associated with the policy.
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The subject attributes for whom the policy grants access.
- subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The resource attributes to which the policy grants access.
- resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
The policy ID.
The href URL that links to the policies API by policy ID.
Specifies the type of access that is granted by the policy.
- control
Permission is granted by the policy.
- grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
The UTC timestamp when the policy was created.
The IAM ID of the entity that created the policy.
The UTC timestamp when the policy was last modified.
The IAM ID of the entity that last modified the policy.
The policy state, either 'deleted' or 'active'.
Possible values: [
active,deleted]The optional last permit time of policy, when passing query parameter format=include_last_permit.
The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit.
The details of the IAM template that was used to create an enterprise-managed policy in your account. When returned, this indicates that the policy is created from and managed by a template in the root enterprise account.
- template
The policy template ID.
Possible values: 1 ≤ length ≤ 51
Template version.
Possible values: 1 ≤ length ≤ 2
Policy assignment ID.
Possible values: 1 ≤ length ≤ 53
Orchestrator template ID.
Possible values: length ≥ 1
Orchestrator template version.
Possible values: length ≥ 1
Status Code
Policy retrieval successful.
The token that you provided is not valid.
You do not have access to retrieve the policy.
The policy was not found.
The requested resource(s) cannot be formatted that uses the requested media type(s).
Too many requests are within a time window.
{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" }{ "id": "12345678-abcd-1a2b-a1b2-1234567890ab", "type": "access", "description": "Viewer role access for all instances of key protect in the account during business hours.", "subject": { "attributes": [ { "key": "iam_id", "operator": "stringEquals", "value": "IBMid-123453user" } ] }, "control": { "grant": { "roles": [ { "role_id": "crn:v1:bluemix:public:iam::::role:Viewer" } ] } }, "resource": { "attributes": [ { "key": "accountId", "operator": "stringEquals", "value": "100abcde100a41abc100aza678abc0zz" }, { "key": "serviceName", "operator": "stringEquals", "value": "kms" } ] }, "rule": { "operator": "and", "conditions": [ { "key": "{{environment.attributes.day_of_week}}", "operator": "dayOfWeekAnyOf", "value": [ "1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00" ] }, { "key": "{{environment.attributes.current_time}}", "operator": "timeGreaterThanOrEquals", "value": "09:00:00+00:00" }, { "key": "{{environment.attributes.current_time}}", "operator": "timeLessThanOrEquals", "value": "17:00:00+00:00" } ] }, "pattern": "time-based-conditions:weekly:custom-hours", "href": "https://iam.cloud.ibm.com/v2/policies/12345678-abcd-1a2b-a1b2-1234567890ab", "created_at": "2018-08-30T14:09:09.907Z", "created_by_id": "IBMid-12345678", "last_modified_at": "2018-08-30T14:09:09.907Z", "last_modified_by_id": "IBMid-12345678", "state": "active" }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to retrieve the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to retrieve the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "unable_to_process", "message": "The requested resource(s) can be formatted that only uses the 'application/json' media type." } ], "status_code": 406 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
Delete a policy by ID
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
Delete a policy by providing a policy ID. A policy cannot be deleted if the subject ID contains a locked service ID. If the subject of the policy is a locked service-id, the request will fail.
DELETE /v2/policies/{id}(iamPolicyManagement *IamPolicyManagementV1) DeleteV2Policy(deleteV2PolicyOptions *DeleteV2PolicyOptions) (response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) DeleteV2PolicyWithContext(ctx context.Context, deleteV2PolicyOptions *DeleteV2PolicyOptions) (response *core.DetailedResponse, err error)
ServiceCall<Void> deleteV2Policy(DeleteV2PolicyOptions deleteV2PolicyOptions)deleteV2Policy(params)
delete_v2_policy(
self,
id: str,
**kwargs,
) -> DetailedResponseRequest
Instantiate the DeleteV2PolicyOptions struct and set the fields to provide parameter values for the DeleteV2Policy method.
Use the DeleteV2PolicyOptions.Builder to create a DeleteV2PolicyOptions object that contains the parameter values for the deleteV2Policy method.
Path Parameters
The policy ID.
Possible values: length ≥ 1
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The DeleteV2Policy options.
The policy ID.
Possible values: length ≥ 1
The deleteV2Policy options.
The policy ID.
Possible values: length ≥ 1
parameters
The policy ID.
Possible values: length ≥ 1
parameters
The policy ID.
Possible values: length ≥ 1
curl -X DELETE 'https://iam.cloud.ibm.com/v2/policies/$POLICY_ID' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
options := iamPolicyManagementService.NewDeleteV2PolicyOptions( examplePolicyID, ) response, err := iamPolicyManagementService.DeleteV2Policy(options) if err != nil { panic(err) }
const params = { id: examplePolicyId, }; try { await iamPolicyManagementService.deleteV2Policy(params); } catch (err) { console.warn(err); }
response = iam_policy_management_service.delete_v2_policy(id=example_policy_id).get_result() print(json.dumps(response, indent=2))
Response
Status Code
Policy deletion successful.
Policy was not valid to delete.
The token that you provided is not valid.
You do not have access to delete the policy.
The policy was not found.
Too many requests are within a time window.
{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Request includes a locked service id, cannot perform action" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_body", "message": "Request includes a locked service id, cannot perform action" } ], "status_code": 400 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "invalid_token", "message": "The provided IAM token is invalid." } ], "status_code": 401 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to delete the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "insufficent_permissions", "message": "You are not allowed to delete the requested policy." } ], "status_code": 403 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "policy_not_found", "message": "Policy with Id POLICY_ID not found." } ], "status_code": 404 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }{ "trace": "26f0b2491ed6425c9e7b0c08a3a645f7", "errors": [ { "code": "too_many_requests", "message": "Too many requests." } ], "status_code": 429 }
List policy templates by attributes
List policy templates and filter by attributes by using query parameters.
The following attributes are supported:
account_id, policy_service_name, policy_service_type, policy_service_group_id and policy_type.
account_id is a required query parameter.
These attributes policy_service_name, policy_service_type and policy_service_group_id are mutually exclusive.
Only policy templates that have the specified attributes and that
the caller has read access to are returned.
If the caller does not have read access to any policy templates an empty array
is returned.
List policy templates and filter by attributes by using query parameters. The following attributes are supported:
account_id, policy_service_name, policy_service_type, policy_service_group_id and policy_type.
account_id is a required query parameter. These attributes policy_service_name, policy_service_type and policy_service_group_id are mutually exclusive. Only policy templates that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policy templates an empty array is returned.
List policy templates and filter by attributes by using query parameters. The following attributes are supported:
account_id, policy_service_name, policy_service_type, policy_service_group_id and policy_type.
account_id is a required query parameter. These attributes policy_service_name, policy_service_type and policy_service_group_id are mutually exclusive. Only policy templates that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policy templates an empty array is returned.
List policy templates and filter by attributes by using query parameters. The following attributes are supported:
account_id, policy_service_name, policy_service_type, policy_service_group_id and policy_type.
account_id is a required query parameter. These attributes policy_service_name, policy_service_type and policy_service_group_id are mutually exclusive. Only policy templates that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policy templates an empty array is returned.
List policy templates and filter by attributes by using query parameters. The following attributes are supported:
account_id, policy_service_name, policy_service_type, policy_service_group_id and policy_type.
account_id is a required query parameter. These attributes policy_service_name, policy_service_type and policy_service_group_id are mutually exclusive. Only policy templates that have the specified attributes and that the caller has read access to are returned. If the caller does not have read access to any policy templates an empty array is returned.
GET /v1/policy_templates
(iamPolicyManagement *IamPolicyManagementV1) ListPolicyTemplates(listPolicyTemplatesOptions *ListPolicyTemplatesOptions) (result *PolicyTemplateCollection, response *core.DetailedResponse, err error)
(iamPolicyManagement *IamPolicyManagementV1) ListPolicyTemplatesWithContext(ctx context.Context, listPolicyTemplatesOptions *ListPolicyTemplatesOptions) (result *PolicyTemplateCollection, response *core.DetailedResponse, err error)
ServiceCall<PolicyTemplateCollection> listPolicyTemplates(ListPolicyTemplatesOptions listPolicyTemplatesOptions)listPolicyTemplates(params)
list_policy_templates(
self,
account_id: str,
*,
accept_language: Optional[str] = None,
state: Optional[str] = None,
name: Optional[str] = None,
policy_service_type: Optional[str] = None,
policy_service_name: Optional[str] = None,
policy_service_group_id: Optional[str] = None,
policy_type: Optional[str] = None,
limit: Optional[int] = None,
start: Optional[str] = None,
**kwargs,
) -> DetailedResponseRequest
Instantiate the ListPolicyTemplatesOptions struct and set the fields to provide parameter values for the ListPolicyTemplates method.
Use the ListPolicyTemplatesOptions.Builder to create a ListPolicyTemplatesOptions object that contains the parameter values for the listPolicyTemplates method.
Custom Headers
Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan)
Possible values: length ≥ 1
Default:
default
Query Parameters
The account GUID that the policy templates belong to.
Possible values: 1 ≤ length ≤ 32, Value must match regular expression
^[A-Za-z0-9-]*$The policy template state.
Allowable values: [
active,deleted]The policy template name.
Possible values: 1 ≤ length ≤ 100
Service type, Optional.
Allowable values: [
service,platform_service]Service name, Optional.
Possible values: length ≥ 1
Service group id, Optional.
Possible values: length ≥ 1
Policy type, Optional.
Allowable values: [
access,authorization]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
^[-A-Za-z0-9+/]*$
WithContext method only
A context.Context instance that you can use to specify a timeout for the operation or to cancel an in-flight request.
The ListPolicyTemplates options.
The account GUID that the policy templates belong to.
Possible values: 1 ≤ length ≤ 32, Value must match regular expression
/^[A-Za-z0-9-]*$/Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultThe policy template state.
Allowable values: [
active,deleted]The policy template name.
Possible values: 1 ≤ length ≤ 100
Service type, Optional.
Allowable values: [
service,platform_service]Service name, Optional.
Possible values: length ≥ 1
Service group id, Optional.
Possible values: length ≥ 1
Policy type, Optional.
Allowable values: [
access,authorization]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Examples:10Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
The listPolicyTemplates options.
The account GUID that the policy templates belong to.
Possible values: 1 ≤ length ≤ 32, Value must match regular expression
/^[A-Za-z0-9-]*$/Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultThe policy template state.
Allowable values: [
active,deleted]The policy template name.
Possible values: 1 ≤ length ≤ 100
Service type, Optional.
Allowable values: [
service,platform_service]Service name, Optional.
Possible values: length ≥ 1
Service group id, Optional.
Possible values: length ≥ 1
Policy type, Optional.
Allowable values: [
access,authorization]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Examples:10Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
parameters
The account GUID that the policy templates belong to.
Possible values: 1 ≤ length ≤ 32, Value must match regular expression
/^[A-Za-z0-9-]*$/Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultThe policy template state.
Allowable values: [
active,deleted]The policy template name.
Possible values: 1 ≤ length ≤ 100
Service type, Optional.
Allowable values: [
service,platform_service]Service name, Optional.
Possible values: length ≥ 1
Service group id, Optional.
Possible values: length ≥ 1
Policy type, Optional.
Allowable values: [
access,authorization]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
parameters
The account GUID that the policy templates belong to.
Possible values: 1 ≤ length ≤ 32, Value must match regular expression
/^[A-Za-z0-9-]*$/Language code for translations
default- Englishde- German (Standard)en- Englishes- Spanish (Spain)fr- French (Standard)it- Italian (Standard)ja- Japaneseko- Koreanpt-br- Portuguese (Brazil)zh-cn- Chinese (Simplified, PRC)zh-tw- (Chinese, Taiwan).
Possible values: length ≥ 1
Default:
defaultThe policy template state.
Allowable values: [
active,deleted]The policy template name.
Possible values: 1 ≤ length ≤ 100
Service type, Optional.
Allowable values: [
service,platform_service]Service name, Optional.
Possible values: length ≥ 1
Service group id, Optional.
Possible values: length ≥ 1
Policy type, Optional.
Allowable values: [
access,authorization]The number of documents to include in the collection.
Possible values: 1 ≤ value ≤ 100
Default:
50Page token that refers to the page of the collection to return.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
curl -X GET 'https://iam.cloud.ibm.com/v1/policy_templates?account_id=$ACCOUNT_ID&state=active' -H 'Authorization: Bearer $TOKEN' -H 'Content-Type: application/json'
listPolicyTemplatesOptions := iamPolicyManagementService.NewListPolicyTemplatesOptions( exampleAccountID, ) policyTemplateCollection, response, err := iamPolicyManagementService.ListPolicyTemplates(listPolicyTemplatesOptions) if err != nil { panic(err) } b, _ := json.MarshalIndent(policyTemplateCollection, "", " ") fmt.Println(string(b))
ListPolicyTemplatesOptions listPolicyTemplatesOptions = new ListPolicyTemplatesOptions.Builder() .accountId(exampleAccountId) .build(); Response<PolicyTemplateCollection> response = service.listPolicyTemplates(listPolicyTemplatesOptions).execute(); PolicyTemplateCollection policyTemplateCollection = response.getResult(); System.out.println(policyTemplateCollection);
const params = { accountId: exampleAccountId, }; let res; try { res = await iamPolicyManagementService.listPolicyTemplates(params); console.log(JSON.stringify(res.result, null, 2)); } catch (err) { console.warn(err); }
response = iam_policy_management_service.list_policy_templates( account_id=example_account_id, ) policy_template_collection = response.get_result() print(json.dumps(policy_template_collection, indent=2))
Response
A collection of policy Templates.
List of policy templates.
Possible values: 0 ≤ number of items ≤ 100
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
Details with href linking to the following page of requested collection.
Details with linking href to previous page of requested collection.
A collection of policy Templates.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- First
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- Next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- Previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policy templates.
Possible values: 0 ≤ number of items ≤ 100
- PolicyTemplates
Required field when creating a new template. Otherwise, this field is optional. If the field is included, it changes the name value for all existing versions of the template.
Possible values: 1 ≤ length ≤ 100, Value must match regular expression
/^.*$/Description of the policy template. This is shown to users in the enterprise account. Use this to describe the purpose or context of the policy for enterprise users managing IAM templates.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/Enterprise account ID where this template is created.
Possible values: 1 ≤ length ≤ 32
Template version.
Possible values: 1 ≤ length ≤ 2
Committed status of the template version.
The core set of properties associated with the template's policy object.
- Policy
The policy type; either 'access' or 'authorization'.
Possible values: [
access,authorization]Description of the policy. This is shown in child accounts when an access group or trusted profile template uses the policy template to assign access.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/The resource attributes to which the policy grants access.
- Resource
List of resource attributes to which the policy grants access.
Possible values: number of items ≥ 1
- Attributes
The name of a resource attribute.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringMatch,stringEqualsAnyOf,stringMatchAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Optional list of resource tags to which the policy grants access.
Possible values: 1 ≤ number of items ≤ 10
- Tags
The name of an access management tag.
Possible values: 1 ≤ length ≤ 128, Value must match regular expression
/^[a-zA-Z0-9 _.-]*$/The value of an access management tag.
Possible values: 1 ≤ length ≤ 1000, Value must match regular expression
/^[a-zA-Z0-9 _*?.-]*$/The operator of an access management tag.
Possible values: [
stringEquals,stringMatch]Possible values: length ≥ 1
The subject attributes for whom the policy grants access.
- Subject
List of subject attributes associated with policy.
Possible values: number of items ≥ 1
- Attributes
The name of a subject attribute. For example, iam_id, access_group_id.
Possible values: length ≥ 1, Value must match regular expression
/^[a-zA-Z0-9_]*$/The operator of an attribute.
Possible values: [
stringEquals,stringExists]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Indicates pattern of rule, either 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or 'time-based-conditions:weekly:custom-hours'.
Possible values: 1 ≤ length ≤ 42, Value must match regular expression
/^[a-z:-]*$/Rule that specifies additional access that is granted (For example, time-based condition).
- Rule
The name of an attribute.
Possible values: length ≥ 1
The operator of an attribute.
Possible values: [
stringEquals,stringExists,stringEqualsAnyOf,stringMatchAnyOf,stringMatch,timeLessThan,timeLessThanOrEquals,timeGreaterThan,timeGreaterThanOrEquals,dateLessThan,dateLessThanOrEquals,dateGreaterThan,dateGreaterThanOrEquals,dateTimeLessThan,dateTimeLessThanOrEquals,dateTimeGreaterThan,dateTimeGreaterThanOrEquals,dayOfWeekEquals,dayOfWeekAnyOf]Possible values: length ≥ 1
The value of a rule, resource, or subject attribute; can be boolean or string for resource and subject attribute. Can be a string or an array of strings (for example, an array of days to permit access) for rule attribute.
Specifies the type of access that is granted by the policy.
- Control
Permission is granted by the policy.
- Grant
A set of role Cloud Resource Names (CRNs) granted by the policy.
Possible values: number of items ≥ 1
- Roles
The role Cloud Resource Name (CRN) granted by the policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'.
State of policy template.
Possible values: [
active,deleted]The policy template ID.
The href URL that links to the policy templates API by policy template ID.
The UTC timestamp when the policy template was created.
The IAM ID of the entity that created the policy template.
The UTC timestamp when the policy template was last modified.
The IAM ID of the entity that last modified the policy template.
A collection of policy Templates.
The number of documents to include per each page of the collection.
Possible values: 1 ≤ value ≤ 100
Details with linking href to first page of requested collection.
- first
The href linking to the page of requested collection.
Details with href linking to the following page of requested collection.
- next
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
Details with linking href to previous page of requested collection.
- previous
The href linking to the page of requested collection.
Page token that refers to the page of the collection.
Possible values: 9 ≤ length ≤ 100, Value must match regular expression
/^[-A-Za-z0-9+\/]*$/
List of policy templates.
Possible values: 0 ≤ number of items ≤ 100
- policyTemplates
Required field when creating a new template. Otherwise, this field is optional. If the field is included, it changes the name value for all existing versions of the template.
Possible values: 1 ≤ length ≤ 100, Value must match regular expression
/^.*$/Description of the policy template. This is shown to users in the enterprise account. Use this to describe the purpose or context of the policy for enterprise users managing IAM templates.
Possible values: 1 ≤ length ≤ 300, Value must match regular expression
/^.*$/Enterprise account ID where this template is created.
Possible values: 1 ≤ length ≤ 32
Template version.
Possible values: 1 ≤ length ≤ 2