コード例 #1
0
            /// <summary>
            /// 获取策略列表
            /// </summary>
            /// <param name="code">角色唯一标志</param>
            /// <param name="page">分页页数,默认为 1</param>
            /// <param name="limit">分页大小,默认为 10</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <PaginatedPolicyAssignments> ListPolicies(
                string code,
                int page  = 1,
                int limit = 10,
                CancellationToken cancellationToken = default
                )
            {
                var param = new PolicyAssignmentsParam()
                {
                    TargetType       = PolicyAssignmentTargetType.ROLE,
                    TargetIdentifier = code,
                    Page             = page,
                    Limit            = limit,
                };
                var res = await client.Request <PolicyAssignmentsResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
            /// <summary>
            /// 获取策略列表
            /// </summary>
            /// <param name="userId">用户 ID</param>
            /// <param name="page">分页页数,默认为 1</param>
            /// <param name="limit">分页大小,默认为 10</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <PaginatedPolicyAssignment> ListPolicies(
                string userId,
                int page  = 1,
                int limit = 10,
                CancellationToken cancellationToken = default)
            {
                var param = new PolicyAssignmentsParam()
                {
                    TargetType       = PolicyAssignmentTargetType.USER,
                    TargetIdentifier = userId,
                    Page             = page,
                    Limit            = limit
                };
                await client.GetAccessToken();

                var res = await client.Request <PolicyAssignmentsResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }
コード例 #3
0
            /// <summary>
            /// 获取策略授权记录
            /// </summary>
            /// <param name="code">策略唯一标志</param>
            /// <param name="page">分页页数,默认为 1</param>
            /// <param name="limit">分页大小,默认为 10</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task <PaginatedPolicyAssignments> ListAssignments(
                string code,
                int page  = 1,
                int limit = 10,
                CancellationToken cancellationToken = default)
            {
                var param = new PolicyAssignmentsParam()
                {
                    Code  = code,
                    Page  = page,
                    Limit = limit,
                };

                await client.GetAccessToken();

                var res = await client.Request <PolicyAssignmentsResponse>(param.CreateRequest(), cancellationToken);

                return(res.Result);
            }