private static void ShowServerTags(EcsClient client) { var req = new ShowServerTagsRequest() { ServerId = "f0a34dd7-a103-400b-a448-9baad3077af2" }; try { var resp = client.ShowServerTags(req); var respStatusCode = resp.HttpStatusCode; var tags = resp.Tags; Console.WriteLine(respStatusCode); foreach (var tag in tags) { Console.WriteLine(tag.Key); Console.WriteLine(tag.Value); } } 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 ShowServerTagsResponse ShowServerTags(ShowServerTagsRequest showServerTagsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("server_id", showServerTagsRequest.ServerId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}/tags", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, showServerTagsRequest); SdkResponse response = DoHttpRequest("GET", request); return(JsonUtils.DeSerialize <ShowServerTagsResponse>(response)); }
/// <summary> /// 查询云服务器标签 /// </summary> public async Task <ShowServerTagsResponse> ShowServerTagsAsync(ShowServerTagsRequest showServerTagsRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("server_id", showServerTagsRequest.ServerId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v1/{project_id}/cloudservers/{server_id}/tags", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", showServerTagsRequest); HttpResponseMessage response = await DoHttpRequestAsync("GET", request); return(JsonUtils.DeSerialize <ShowServerTagsResponse>(response)); }