Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
project_id |
Yes |
String |
Project ID |
topic_urn |
Yes |
String |
Unique resource ID of a topic. You can obtain it by referring to Querying Topics. |
name |
Yes |
String |
Specifies the policy name. Only specified policy names are supported. For details, see Topic Attribute List. |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
value |
Yes |
String |
Topic attribute value
For details, see Table 1. |
Parameter |
Description |
Constraint |
|---|---|---|
Version |
Policy specification version |
Only 2016-09-07 is supported. |
Id |
Policy ID, which uniquely identifies a policy |
Id must be specified. |
Statement |
Statements used to configure a topic policy. Each topic policy may contain one or more statements. You can use statements to grant topic permissions to other users or cloud services. |
A policy must contain at least one statement. For details about elements in a statement, see Table 2. |
Element |
Description |
Constraint |
|---|---|---|
Sid |
Statement ID |
The statement ID must be unique, for example, statement01 or statement02. |
Effect |
Statement effect |
The effect can be Allow or Deny. |
Principal NotPrincipal |
|
Either the Principal or NotPrincipal element must be configured.
|
Action NotAction |
|
Either Action or NotAction must be configured. The following actions are supported:
|
Resource |
Specifies the topic the statement applies to. |
Either Resource or NotResource must be configured. You need to enter a topic URN. |
NotResource |
Specifies the topic the statement does not apply to. |
Either Resource or NotResource must be configured. You need to enter a topic URN. |
PUT https://{SMN_Endpoint}/v2/{project_id}/notifications/topics/{topic_urn}/attributes/access_policy
{
"value": "{
\"Version\": \"2016-09-07\",
\"Id\": \"__default_policy_ID\",
\"Statement\": [
{
\"Sid\": \"__user_pub_0\",
\"Effect\": \"Allow\",
\"Principal\": {
\"CSP\": [
\"urn:csp:iam::{domainID}:root\"
]
},
\"Action\": [\"SMN:Publish\",\"SMN:QueryTopicDetail\"],
\"Resource\": \"{topic_urn}\"
},
{
\"Sid\": \"__service_pub_0\",
\"Effect\": \"Allow\",
\"Principal\": {
\"Service\": [\"obs\"]
},
\"Action\": [\"SMN:Publish\",\"SMN:QueryTopicDetail\"],
\"Resource\": \"{topic_urn}\"
}
]
}"
}
Replace {project_id}, {domainID}, and {topic_urn} with the actual values.
domainID indicates the user's account ID. To obtain it, log in to the SMN console, click My Credentials in the username drop-down list on the upper right.
Parameter |
Type |
Description |
|---|---|---|
request_id |
String |
Request ID, which is unique |
{
"request_id":"6837531fd3f54550927b930180a706bf"
}
See Returned Value.
See Error Codes.