Example #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
        }