Exemplo n.º 1
0
        /// <summary>Snippet for ExportAssets</summary>
        public void ExportAssets_RequestObject()
        {
            // Snippet: ExportAssets(ExportAssetsRequest,CallSettings)
            // Create client
            AssetServiceClient assetServiceClient = AssetServiceClient.Create();
            // Initialize request argument(s)
            ExportAssetsRequest request = new ExportAssetsRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                OutputConfig        = new OutputConfig(),
            };
            // Make the request
            Operation <ExportAssetsResponse, ExportAssetsRequest> response =
                assetServiceClient.ExportAssets(request);

            // Poll until the returned long-running operation is complete
            Operation <ExportAssetsResponse, ExportAssetsRequest> completedResponse =
                response.PollUntilCompleted();
            // Retrieve the operation result
            ExportAssetsResponse 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 <ExportAssetsResponse, ExportAssetsRequest> retrievedResponse =
                assetServiceClient.PollOnceExportAssets(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ExportAssetsResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Exemplo n.º 2
0
    public static void Main(string[] args)
    {
        string              bucketName    = "YOUR-BUCKET-NAME";
        string              projectId     = "YOUR-GOOGLE-PROJECT-ID";
        string              assetDumpFile = String.Format("gs://{0}/my-assets.txt", bucketName);
        AssetServiceClient  client        = AssetServiceClient.Create();
        ExportAssetsRequest request       = new ExportAssetsRequest
        {
            ParentAsProjectName = new ProjectName(projectId),
            OutputConfig        = new OutputConfig
            {
                GcsDestination = new GcsDestination {
                    Uri = assetDumpFile
                }
            }
        };
        // Start the long-running export operation
        var operation = client.ExportAssets(request);

        // Wait for it to complete (or fail)
        operation = operation.PollUntilCompleted();
        // Extract the result
        ExportAssetsResponse response = operation.Result;

        Console.WriteLine(response);
    }
Exemplo n.º 3
0
        /// <summary>Snippet for ExportAssets</summary>
        public void ExportAssetsRequestObject()
        {
            // Snippet: ExportAssets(ExportAssetsRequest, CallSettings)
            // Create client
            AssetServiceClient assetServiceClient = AssetServiceClient.Create();
            // Initialize request argument(s)
            ExportAssetsRequest request = new ExportAssetsRequest
            {
                ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
                ReadTime             = new Timestamp(),
                AssetTypes           = { "", },
                ContentType          = ContentType.Unspecified,
                OutputConfig         = new OutputConfig(),
            };
            // Make the request
            Operation <ExportAssetsResponse, ExportAssetsRequest> response = assetServiceClient.ExportAssets(request);

            // Poll until the returned long-running operation is complete
            Operation <ExportAssetsResponse, ExportAssetsRequest> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            ExportAssetsResponse 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 <ExportAssetsResponse, ExportAssetsRequest> retrievedResponse = assetServiceClient.PollOnceExportAssets(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ExportAssetsResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Exemplo n.º 4
0
        /// <summary>Snippet for ExportAssetsAsync</summary>
        public async Task ExportAssetsAsync_RequestObject()
        {
            // Snippet: ExportAssetsAsync(ExportAssetsRequest,CallSettings)
            // Create client
            AssetServiceClient assetServiceClient = await AssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            ExportAssetsRequest request = new ExportAssetsRequest
            {
                Parent       = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(),
                ContentTypes = { },
                OutputConfig = new OutputConfig(),
            };
            // Make the request
            Operation <ExportAssetsResponse, ExportAssetsRequest> response =
                await assetServiceClient.ExportAssetsAsync(request);

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

            // Retrieve the operation result
            ExportAssetsResponse 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 <ExportAssetsResponse, ExportAssetsRequest> retrievedResponse =
                await assetServiceClient.PollOnceExportAssetsAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                ExportAssetsResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Exemplo n.º 5
0
    public ExportAssetsResponse ExportAssets(string bucketName, string projectId)
    {
        string assetDumpFile = $"gs://{bucketName}/my-assets.txt";
        // Create the client
        AssetServiceClient client = AssetServiceClient.Create();
        // Build the request
        ExportAssetsRequest request = new ExportAssetsRequest
        {
            ParentAsResourceName = ProjectName.FromProject(projectId),
            OutputConfig         = new OutputConfig
            {
                GcsDestination = new GcsDestination {
                    Uri = assetDumpFile
                }
            }
        };
        // Start the long-running export operation
        var operation = client.ExportAssets(request);

        // Wait for it to complete (or fail)
        operation = operation.PollUntilCompleted();
        // Return the result
        return(operation.Result);
    }