コード例 #1
0
        public override Credentials ProcessAuthParams(SdkHttpClient client, string regionId)
        {
            if (ProjectId != null)
            {
                return(this);
            }

            var akWithName = Ak + regionId;
            var projectId  = AuthCache.GetAuth(akWithName);

            if (!string.IsNullOrEmpty(projectId))
            {
                ProjectId = projectId;
                return(this);
            }

            IamEndpoint = IsNullOrEmpty(IamEndpoint) ? IamService.DefaultIamEndpoint : IamEndpoint;
            var request = IamService.GetKeystoneListProjectsRequest(IamEndpoint, regionId);

            request = SignAuthRequest(request).Result;
            try
            {
                ProjectId = IamService.KeystoneListProjects(client, request);
                AuthCache.PutAuth(akWithName, ProjectId);
                return(this);
            }
            catch (ServiceResponseException e)
            {
                throw new ArgumentException("Failed to get project id, " + e.ErrorMsg);
            }
        }
コード例 #2
0
        public override Credentials ProcessAuthParams(SdkHttpClient client, string regionId)
        {
            if (DomainId != null)
            {
                return(this);
            }

            var domainId = AuthCache.GetAuth(Ak);

            if (!string.IsNullOrEmpty(domainId))
            {
                DomainId = domainId;
                return(this);
            }

            IamEndpoint = IsNullOrEmpty(IamEndpoint) ? IamService.DefaultIamEndpoint : IamEndpoint;
            var request = IamService.GetKeystoneListAuthDomainsRequest(IamEndpoint);

            request = SignAuthRequest(request).Result;
            try
            {
                DomainId = IamService.KeystoneListAuthDomains(client, request);
                AuthCache.PutAuth(Ak, DomainId);
                return(this);
            }
            catch (ServiceResponseException e)
            {
                throw new ArgumentException("Failed to get domain id, " + e.ErrorMsg);
            }
        }