Updated on 2025-11-05 GMT+08:00

Obtaining Access Policy Details

Function

This API is used to obtain an access policy.

Calling Method

For details, see Calling APIs.

URI

GET /api/v3/access-policies/{policy_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

policy_id

Yes

String

Definition:

Access policy ID. For details about how to obtain the access policy ID, see Obtaining the Access Policy List.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

kind

String

Definition:

API type

Constraints:

The value cannot be changed.

Range:

N/A

Default Value:

AccessPolicy

apiVersion

String

Definition:

API version

Constraints:

The value cannot be changed.

Range:

N/A

Default Value:

v3

name

String

Definition

Access policy name.

Constraints

Enter 1 to 56 characters starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed.

Range

N/A

Default Value

N/A

policyId

String

Definition:

Permission ID

Constraints:

The value is automatically generated and cannot be changed.

Range:

N/A

Default Value:

N/A

clusters

Array of strings

Definition:

List of cluster IDs. Wildcards (*) are allowed, which indicate all clusters.

Constraints:

A maximum of 200 clusters can be authorized at a time.

Range:

[*] or cluster ID list

Default Value:

N/A

accessScope

AccessScope object

Definition:

Access scope, which is used to specify the cluster and namespace to be authorized

Constraints:

N/A

policyType

String

Definition

Permission type

Constraints

N/A

Range

  • CCEClusterAdminPolicy: Administrator permissions, including read and write permissions on all resources in all namespaces.

  • CCEAdminPolicy: O&M permissions, including read and write permissions on most resources in all namespaces, and read-only permissions on nodes, storage volumes, namespaces, and quota management.

  • CCEEditPolicy: Developer permissions, including read and write permissions on most resources in all or selected namespaces. If this kind of permissions is configured for all namespaces, its capability is the same as the O&M permissions.

  • CCEViewPolicy: read-only permissions on most resources in all or selected namespaces.

Default Value

N/A

principal

Principal object

Definition:

Authorization object

Constraints:

N/A

createTime

String

Definition:

Creation time

Constraints:

N/A

Range:

N/A

Default Value:

N/A

updateTime

String

Definition:

Update time

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Table 3 AccessScope

Parameter

Type

Description

namespaces

Array of strings

Definition

List of cluster namespaces. Wildcards (*) are allowed to indicate all namespaces. If different clusters are selected, the namespace list can be a collection of multiple clusters. When RBAC authorization is used, CCE automatically checks whether the namespaces exist in the clusters.

Constraints

A maximum of 500 namespaces can be authorized at a time.

Range

[*] or cluster namespace list

Default Value

N/A

Table 4 Principal

Parameter

Type

Description

type

String

Definition:

Type of the authorization object

Constraints:

N/A

Range:

  • user: user

  • group: user group

  • agency: agency account

Default Value:

N/A

ids

Array of strings

Definition:

List of IDs of authorized objects. Enter the IDs based on the object type, user, user group, and agency account.

Constraints:

A maximum of 500 users or user groups can be authorized at a time.

Range:

N/A

Default Value:

N/A

Example Requests

None

Example Responses

Status code: 200

{
  "kind" : "AccessPolicy",
  "apiVersion" : "v3",
  "name" : "test-access-policy",
  "policyId" : "402358e8-2e3a-4531-bae7-fe9cba14d0d1",
  "clusters" : [ "*" ],
  "accessScope" : {
    "namespaces" : [ "*" ]
  },
  "policyType" : "CCEAdminPolicy",
  "principal" : {
    "type" : "user",
    "ids" : [ "069fcc2116c347b89869eae3cdxxxxxx1", "069fcc2116c347b89869eae3cdxxxxxx2" ]
  },
  "createTime" : "",
  "updateTime" : ""
}

SDK Sample Code

The SDK sample code is as follows.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.cce.v3.region.CceRegion;
import com.huaweicloud.sdk.cce.v3.*;
import com.huaweicloud.sdk.cce.v3.model.*;


public class GetAccessPolicySolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        CceClient client = CceClient.newBuilder()
                .withCredential(auth)
                .withRegion(CceRegion.valueOf("<YOUR REGION>"))
                .build();
        GetAccessPolicyRequest request = new GetAccessPolicyRequest();
        request.withPolicyId("{policy_id}");
        try {
            GetAccessPolicyResponse response = client.getAccessPolicy(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcce.v3.region.cce_region import CceRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkcce.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = BasicCredentials(ak, sk)

    client = CceClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(CceRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = GetAccessPolicyRequest()
        request.policy_id = "{policy_id}"
        response = client.get_access_policy(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    cce "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cce/v3/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := cce.NewCceClient(
        cce.CceClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.GetAccessPolicyRequest{}
	request.PolicyId = "{policy_id}"
	response, err := client.GetAccessPolicy(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Error Codes

See Error Codes.