Beispiel #1
0
        // Credential管理

        private static void CreateTemporaryAccessKeyByAgency(IamClient iamClient)
        {
            var createTemporaryAccessKeyByAgencyRequest = new CreateTemporaryAccessKeyByAgencyRequest()
            {
                Body = new CreateTemporaryAccessKeyByAgencyRequestBody()
                {
                    Auth = new AgencyAuth()
                    {
                        Identity = new AgencyAuthIdentity()
                        {
                            Methods = new List <AgencyAuthIdentity.MethodsEnum>()
                            {
                                AgencyAuthIdentity.MethodsEnum.ASSUME_ROLE
                            },
                            AssumeRole = new IdentityAssumerole()
                            {
                                DomainName      = "",
                                AgencyName      = "",
                                DomainId        = "",
                                DurationSeconds = 900,
                                SessionUser     = new AssumeroleSessionuser()
                                {
                                    Name = ""
                                }
                            }
                        }
                    }
                }
            };

            try
            {
                var createTemporaryAccessKeyByAgencyResponse =
                    iamClient.CreateTemporaryAccessKeyByAgency(createTemporaryAccessKeyByAgencyRequest);
                Console.WriteLine(JsonConvert.SerializeObject(createTemporaryAccessKeyByAgencyResponse.Credential));
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }