Exemplo n.º 1
0
        //copy image in region
        private static void CopyImageInRegion(ImsClient imsV1Client)
        {
            CopyImageInRegionRequest imageRegionCopyRequest = new CopyImageInRegionRequest()
            {
                ImageId = "0f5075af-13b1-44f7-9d9b-4f9490a87719",
                Body    = new CopyImageInRegionRequestBody()
                {
                    Name        = "copy-test",
                    Description = "copy in region"
                }
            };

            try
            {
                var copyResponse = imsV1Client.CopyImageInRegion(imageRegionCopyRequest);
                Console.WriteLine(copyResponse.JobId);
            }
            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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Region内复制镜像
        /// </summary>
        public CopyImageInRegionResponse CopyImageInRegion(CopyImageInRegionRequest copyImageInRegionRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("image_id", copyImageInRegionRequest.ImageId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v1/cloudimages/{image_id}/copy", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", copyImageInRegionRequest);
            HttpResponseMessage response = DoHttpRequestSync("POST", request);

            return(JsonUtils.DeSerialize <CopyImageInRegionResponse>(response));
        }