Esempio n. 1
0
        /// <summary>Snippet for DeleteFeed</summary>
        public void DeleteFeedRequestObject()
        {
            // Snippet: DeleteFeed(DeleteFeedRequest, CallSettings)
            // Create client
            AssetServiceClient assetServiceClient = AssetServiceClient.Create();
            // Initialize request argument(s)
            DeleteFeedRequest request = new DeleteFeedRequest
            {
                FeedName = FeedName.FromProjectFeed("[PROJECT]", "[FEED]"),
            };

            // Make the request
            assetServiceClient.DeleteFeed(request);
            // End snippet
        }
Esempio n. 2
0
 /// <summary>Snippet for AnalyzeIamPolicy</summary>
 public void AnalyzeIamPolicyRequestObject()
 {
     // Snippet: AnalyzeIamPolicy(AnalyzeIamPolicyRequest, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     AnalyzeIamPolicyRequest request = new AnalyzeIamPolicyRequest
     {
         AnalysisQuery    = new IamPolicyAnalysisQuery(),
         ExecutionTimeout = new Duration(),
     };
     // Make the request
     AnalyzeIamPolicyResponse response = assetServiceClient.AnalyzeIamPolicy(request);
     // End snippet
 }
Esempio n. 3
0
 /// <summary>Snippet for BatchGetAssetsHistory</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void BatchGetAssetsHistoryRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
     {
         ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
         AssetNames           = { "", },
         ContentType          = ContentType.Unspecified,
         ReadTimeWindow       = new TimeWindow(),
     };
     // Make the request
     BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request);
 }
Esempio n. 4
0
 /// <summary>Snippet for UpdateFeed</summary>
 public void UpdateFeedRequestObject()
 {
     // Snippet: UpdateFeed(UpdateFeedRequest, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     UpdateFeedRequest request = new UpdateFeedRequest
     {
         Feed       = new Feed(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Feed response = assetServiceClient.UpdateFeed(request);
     // End snippet
 }
Esempio n. 5
0
 /// <summary>Snippet for MutateAssets</summary>
 public void MutateAssets()
 {
     // Snippet: MutateAssets(string, IEnumerable<AssetOperation>, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <AssetOperation> operations = new AssetOperation[]
     {
         new AssetOperation(),
     };
     // Make the request
     MutateAssetsResponse response = assetServiceClient.MutateAssets(customerId, operations);
     // End snippet
 }
        /// <summary>Snippet for SearchAllResources</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void SearchAllResourcesRequestObject()
        {
            // Create client
            AssetServiceClient assetServiceClient = AssetServiceClient.Create();
            // Initialize request argument(s)
            SearchAllResourcesRequest request = new SearchAllResourcesRequest
            {
                Scope      = "",
                Query      = "",
                AssetTypes = { "", },
                OrderBy    = "",
            };
            // Make the request
            PagedEnumerable <SearchAllResourcesResponse, ResourceSearchResult> response = assetServiceClient.SearchAllResources(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (ResourceSearchResult item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (SearchAllResourcesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (ResourceSearchResult item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <ResourceSearchResult> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (ResourceSearchResult item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
        }
Esempio n. 7
0
        /// <summary>Snippet for ListAssets</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void ListAssetsRequestObject()
        {
            // Create client
            AssetServiceClient assetServiceClient = AssetServiceClient.Create();
            // Initialize request argument(s)
            ListAssetsRequest request = new ListAssetsRequest
            {
                ParentAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
                ReadTime             = new Timestamp(),
                AssetTypes           = { "", },
                ContentType          = ContentType.Unspecified,
            };
            // Make the request
            PagedEnumerable <ListAssetsResponse, Asset> response = assetServiceClient.ListAssets(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Asset item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListAssetsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Asset item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int          pageSize   = 10;
            Page <Asset> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Asset item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
        }
Esempio n. 8
0
 /// <summary>Snippet for MutateAssets</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAssetsRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     MutateAssetsRequest request = new MutateAssetsRequest
     {
         CustomerId = "",
         Operations =
         {
             new AssetOperation(),
         },
     };
     // Make the request
     MutateAssetsResponse response = assetServiceClient.MutateAssets(request);
 }
Esempio n. 9
0
 /// <summary>Snippet for BatchGetAssetsHistory</summary>
 public void BatchGetAssetsHistory_RequestObject()
 {
     // Snippet: BatchGetAssetsHistory(BatchGetAssetsHistoryRequest,CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
     {
         ParentAsProjectName = new ProjectName("[PROJECT]"),
         ContentType         = ContentType.Unspecified,
         ReadTimeWindow      = new TimeWindow(),
     };
     // Make the request
     BatchGetAssetsHistoryResponse response = assetServiceClient.BatchGetAssetsHistory(request);
     // End snippet
 }
Esempio n. 10
0
 /// <summary>Snippet for CreateFeed</summary>
 public void CreateFeed_RequestObject()
 {
     // Snippet: CreateFeed(CreateFeedRequest,CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     CreateFeedRequest request = new CreateFeedRequest
     {
         Parent = "",
         FeedId = "",
         Feed   = new Feed(),
     };
     // Make the request
     Feed response = assetServiceClient.CreateFeed(request);
     // End snippet
 }
Esempio n. 11
0
        /// <summary>Snippet for SearchAllResources</summary>
        public void SearchAllResources()
        {
            // Snippet: SearchAllResources(string, string, IEnumerable<string>, string, int?, CallSettings)
            // Create client
            AssetServiceClient assetServiceClient = AssetServiceClient.Create();
            // Initialize request argument(s)
            string scope = "";
            string query = "";
            IEnumerable <string> assetTypes = new string[] { "", };
            // Make the request
            PagedEnumerable <SearchAllResourcesResponse, StandardResourceMetadata> response = assetServiceClient.SearchAllResources(scope, query, assetTypes);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (StandardResourceMetadata item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (SearchAllResourcesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (StandardResourceMetadata item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <StandardResourceMetadata> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (StandardResourceMetadata item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
Esempio n. 12
0
    public PagedEnumerable <ListAssetsResponse, Asset> ListAssets(string projectId)
    {
        // Create the client.
        AssetServiceClient client = AssetServiceClient.Create();

        // Build the request.
        ListAssetsRequest request = new ListAssetsRequest
        {
            ParentAsResourceName = ProjectName.FromProject(projectId),
            ContentType          = ContentType.Resource,
        };

        // Call the API.
        PagedEnumerable <ListAssetsResponse, Asset> response = client.ListAssets(request);

        // Return the result.
        return(response);
    }
 /// <summary>Snippet for MutateAssets</summary>
 public void MutateAssetsRequestObject()
 {
     // Snippet: MutateAssets(MutateAssetsRequest, CallSettings)
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     MutateAssetsRequest request = new MutateAssetsRequest
     {
         CustomerId = "",
         Operations =
         {
             new AssetOperation(),
         },
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateAssetsResponse response = assetServiceClient.MutateAssets(request);
     // End snippet
 }
 /// <summary>Snippet for MutateAssets</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAssetsRequestObject()
 {
     // Create client
     AssetServiceClient assetServiceClient = AssetServiceClient.Create();
     // Initialize request argument(s)
     MutateAssetsRequest request = new MutateAssetsRequest
     {
         CustomerId = "",
         Operations =
         {
             new AssetOperation(),
         },
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
         ValidateOnly        = false,
         PartialFailure      = false,
     };
     // Make the request
     MutateAssetsResponse response = assetServiceClient.MutateAssets(request);
 }
Esempio n. 15
0
    public AnalyzeIamPolicyLongrunningResponse AnalyzeIamPolicyLongrunning(
        string scope, string fullResourceName, string dataset, string tablePrefix)
    {
        // Create the client.
        AssetServiceClient client = AssetServiceClient.Create();

        // Build the request.
        AnalyzeIamPolicyLongrunningRequest request = new AnalyzeIamPolicyLongrunningRequest
        {
            AnalysisQuery = new IamPolicyAnalysisQuery
            {
                Scope            = scope,
                ResourceSelector = new IamPolicyAnalysisQuery.Types.ResourceSelector
                {
                    FullResourceName = fullResourceName,
                },
                Options = new IamPolicyAnalysisQuery.Types.Options
                {
                    ExpandGroups     = true,
                    OutputGroupEdges = true,
                },
            },
            OutputConfig = new IamPolicyAnalysisOutputConfig
            {
                BigqueryDestination = new IamPolicyAnalysisOutputConfig.Types.BigQueryDestination
                {
                    Dataset     = dataset,
                    TablePrefix = tablePrefix,
                },
            },
        };

        // Start the analyze long-running operation
        var operation = client.AnalyzeIamPolicyLongrunning(request);

        // Wait for it to complete
        operation = operation.PollUntilCompleted();

        // Return the operation result. If the operation has failed
        // calling Result will throw.
        return(operation.Result);
    }
Esempio n. 16
0
    public SearchAllIamPoliciesResponse SearchAllIamPolicies(string scope, string query)
    {
        // Create the client.
        AssetServiceClient client = AssetServiceClient.Create();

        // Build the request.
        SearchAllIamPoliciesRequest request = new SearchAllIamPoliciesRequest
        {
            Scope = scope,
            Query = query,
        };

        // Call the API.
        PagedEnumerable <SearchAllIamPoliciesResponse, IamPolicySearchResult> response = client.SearchAllIamPolicies(request);

        // Return the first page.
        IEnumerable <SearchAllIamPoliciesResponse> byPages = response.AsRawResponses();

        return(byPages.First());
    }
    public AnalyzeIamPolicyLongrunningRequest AnalyzeIamPolicyLongrunning(
        string scope, string fullResourceName, string uri)
    {
        // Create the client.
        AssetServiceClient client = AssetServiceClient.Create();

        // Build the request.
        AnalyzeIamPolicyLongrunningRequest request = new AnalyzeIamPolicyLongrunningRequest
        {
            AnalysisQuery = new IamPolicyAnalysisQuery
            {
                Scope            = scope,
                ResourceSelector = new IamPolicyAnalysisQuery.Types.ResourceSelector
                {
                    FullResourceName = fullResourceName,
                },
                Options = new IamPolicyAnalysisQuery.Types.Options
                {
                    ExpandGroups     = true,
                    OutputGroupEdges = true,
                },
            },
            OutputConfig = new IamPolicyAnalysisOutputConfig
            {
                GcsDestination = new IamPolicyAnalysisOutputConfig.Types.GcsDestination
                {
                    Uri = uri,
                },
            },
        };

        // Start the analyze long-running operation
        var operation = client.AnalyzeIamPolicyLongrunning(request);

        // Wait for it to complete
        operation = operation.PollUntilCompleted();
        // Return the metadata(request)
        return(operation.Metadata);
    }
Esempio n. 18
0
    public static void Main(string[] args)
    {
        // Asset names, e.g.: //storage.googleapis.com/[YOUR_BUCKET_NAME]
        string[] assetNames = { "ASSET-NAME" };
        string   projectId  = "YOUR-GOOGLE-PROJECT-ID";

        BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
        {
            ParentAsProjectName = new ProjectName(projectId),
            ContentType         = ContentType.Resource,
            ReadTimeWindow      = new TimeWindow
            {
                StartTime = Timestamp.FromDateTime(System.DateTime.UtcNow)
            }
        };

        request.AssetNames.AddRange(assetNames);
        AssetServiceClient            client   = AssetServiceClient.Create();
        BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request);

        Console.WriteLine(response);
    }
Esempio n. 19
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
            {
                Parent       = new Google.Api.Gax.ResourceNames.ProjectName("[PROJECT]").ToString(),
                ContentTypes = { },
                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
        }
    public BatchGetAssetsHistoryResponse BatchGetAssetsHistory(string[] assetNames, string projectId)
    {
        // Create the client.
        AssetServiceClient client = AssetServiceClient.Create();

        // Build the request.
        BatchGetAssetsHistoryRequest request = new BatchGetAssetsHistoryRequest
        {
            ParentAsResourceName = ProjectName.FromProject(projectId),
            ContentType          = ContentType.Resource,
            ReadTimeWindow       = new TimeWindow
            {
                StartTime = Timestamp.FromDateTime(DateTime.UtcNow)
            }
        };

        request.AssetNames.AddRange(assetNames);

        // Call the API.
        BatchGetAssetsHistoryResponse response = client.BatchGetAssetsHistory(request);

        // Return the result.
        return(response);
    }
Esempio n. 21
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);
    }