/****************************************DatastoreVersions End***************************************************/ /********************************************Flavors Start*******************************************************/ /// <summary> /// 查询所有实例规格信息 /// </summary> public static void ListFlavor(DdsClient client) { ListFlavorsRequest req = new ListFlavorsRequest { Region = "cn-xianhz-1" }; try { ListFlavorsResponse resp = client.ListFlavors(req); foreach (var flavor in resp.Flavors) { Console.WriteLine(flavor.EngineName); Console.WriteLine(flavor.Type); } Console.WriteLine("List Flavor Success!"); } 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); } }
private static void listFlavors(DcsClient dcsClient) { var listFlavorsRequest = new ListFlavorsRequest() { CacheMode = "single", Capacity = "2", CpuType = ListFlavorsRequest.CpuTypeEnum.AARCH64, Engine = "Redis", EngineVersion = "4.0" }; try { var response = dcsClient.ListFlavors(listFlavorsRequest); Console.WriteLine(response.GetHttpBody()); } 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); } }
private static void ListFlavors(EcsClient client) { var req = new ListFlavorsRequest { AvailabilityZone = "br-iaas-odin1a" }; try { var resp = client.ListFlavors(req); var respStatusCode = resp.HttpStatusCode; Console.WriteLine(respStatusCode); var flavors = resp.Flavors; foreach (var flavor in flavors) { Console.WriteLine(flavor.Id); } } 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); } }
/// <summary> /// 查询指定条件下的所有实例规格信息 /// </summary> public ListFlavorsResponse ListFlavors(ListFlavorsRequest listFlavorsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/flavors", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, listFlavorsRequest); SdkResponse response = DoHttpRequest("GET", request); return(JsonUtils.DeSerialize <ListFlavorsResponse>(response)); }
/// <summary> /// 查询产品规格 /// </summary> public async Task <ListFlavorsResponse> ListFlavorsAsync(ListFlavorsRequest listFlavorsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v2/{project_id}/flavors", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, listFlavorsRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ListFlavorsResponse>(response)); }
/// <summary> /// 查询规格详情和规格扩展信息列表 /// </summary> public ListFlavorsResponse ListFlavors(ListFlavorsRequest listFlavorsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/flavors", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", listFlavorsRequest); HttpResponseMessage response = DoHttpRequestSync("GET", request); return(JsonUtils.DeSerialize <ListFlavorsResponse>(response)); }