Exemple #1
0
        public static void DetachRolePolicy()
        {
            var               client      = new AmazonIdentityManagementServiceClient();
            string            policy      = GenerateRolePolicyDocument();
            CreateRoleRequest roleRequest = new CreateRoleRequest()
            {
                RoleName = "tester",
                AssumeRolePolicyDocument = policy
            };

            var request = new DetachRolePolicyRequest()
            {
                PolicyArn = "arn:aws:iam::123456789:policy/DemoEC2Permissions",
                RoleName  = "tester"
            };

            try
            {
                var response = client.DetachRolePolicy(request);
                Console.WriteLine("Policy DemoEC2Permissions detached from Role 'tester'");
            }
            catch (NoSuchEntityException e)
            {
                Console.WriteLine
                    (e.Message);
            }
            catch (InvalidInputException i)
            {
                Console.WriteLine
                    (i.Message);
            }
        }
        /// <summary>
        /// 本接口(DetachRolePolicy)用于解除绑定角色的策略。
        /// </summary>
        /// <param name="req">参考<see cref="DetachRolePolicyRequest"/></param>
        /// <returns>参考<see cref="DetachRolePolicyResponse"/>实例</returns>
        public async Task <DetachRolePolicyResponse> DetachRolePolicy(DetachRolePolicyRequest req)
        {
            JsonResponseModel <DetachRolePolicyResponse> rsp = null;

            try
            {
                var strResp = await this.InternalRequest(req, "DetachRolePolicy");

                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DetachRolePolicyResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
 public Task <DetachRolePolicyResponse> DetachRolePolicyAsync(DetachRolePolicyRequest request,
                                                              CancellationToken cancellationToken = new CancellationToken())
 {
     throw new System.NotImplementedException();
 }