public static string KeystoneListProjects(SdkHttpClient client, HttpRequest request) { var message = client.InitHttpRequest(request, true); try { var response = client.DoHttpRequest(message).Result; if ((int)response.StatusCode >= 400) { throw ExceptionUtils.GetException(response); } var data = JsonUtils.DeSerialize <KeystoneListProjectsResponse>(response); // TODO support create new project id here if (data?.Projects == null || data.Projects?.Count == 0) { throw new ArgumentException("Failed to get project id."); } if (data.Projects.Count == 1) { return(data.Projects[0].Id); } throw new ArgumentException( "Multiple project ids have been returned, please specify one when initializing credentials."); } catch (AggregateException aggregateException) { throw new ConnectionException(aggregateException.Message); } }
public static string KeystoneListAuthDomains(SdkHttpClient client, HttpRequest request) { var message = client.InitHttpRequest(request, true); try { var response = client.DoHttpRequest(message).Result; if ((int)response.StatusCode >= 400) { throw ExceptionUtils.GetException(response); } var data = JsonUtils.DeSerialize <KeystoneListAuthDomainsResponse>(response); if (data?.Domains != null && data.Domains.Count > 0) { return(data.Domains[0].Id); } throw new ArgumentException("Failed to get domain id."); } catch (AggregateException aggregateException) { throw new ConnectionException(aggregateException.Message); } }