Exemple #1
0
        /// <summary>Snippet for BatchMigrateResourcesAsync</summary>
        public async Task BatchMigrateResourcesResourceNamesAsync()
        {
            // Snippet: BatchMigrateResourcesAsync(LocationName, IEnumerable<MigrateResourceRequest>, CallSettings)
            // Additional: BatchMigrateResourcesAsync(LocationName, IEnumerable<MigrateResourceRequest>, CancellationToken)
            // Create client
            MigrationServiceClient migrationServiceClient = await MigrationServiceClient.CreateAsync();

            // Initialize request argument(s)
            LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            IEnumerable <MigrateResourceRequest> migrateResourceRequests = new MigrateResourceRequest[]
            {
                new MigrateResourceRequest(),
            };
            // Make the request
            Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> response = await migrationServiceClient.BatchMigrateResourcesAsync(parent, migrateResourceRequests);

            // Poll until the returned long-running operation is complete
            Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            BatchMigrateResourcesResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> retrievedResponse = await migrationServiceClient.PollOnceBatchMigrateResourcesAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                BatchMigrateResourcesResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Exemple #2
0
        /// <summary>Snippet for BatchMigrateResources</summary>
        public void BatchMigrateResources()
        {
            // Snippet: BatchMigrateResources(string, IEnumerable<MigrateResourceRequest>, CallSettings)
            // Create client
            MigrationServiceClient migrationServiceClient = MigrationServiceClient.Create();
            // Initialize request argument(s)
            string parent = "projects/[PROJECT]/locations/[LOCATION]";
            IEnumerable <MigrateResourceRequest> migrateResourceRequests = new MigrateResourceRequest[]
            {
                new MigrateResourceRequest(),
            };
            // Make the request
            Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> response = migrationServiceClient.BatchMigrateResources(parent, migrateResourceRequests);

            // Poll until the returned long-running operation is complete
            Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            BatchMigrateResourcesResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <BatchMigrateResourcesResponse, BatchMigrateResourcesOperationMetadata> retrievedResponse = migrationServiceClient.PollOnceBatchMigrateResources(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                BatchMigrateResourcesResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Exemple #3
0
        /// <summary>
        /// 迁移资源
        /// </summary>
        public MigrateResourceResponse MigrateResource(MigrateResourceRequest migrateResourceRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("enterprise_project_id", migrateResourceRequest.EnterpriseProjectId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v1.0/enterprise-projects/{enterprise_project_id}/resources-migrate", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", migrateResourceRequest);
            HttpResponseMessage response = DoHttpRequestSync("POST", request);

            return(JsonUtils.DeSerializeNull <MigrateResourceResponse>(response));
        }