Esempio n. 1
0
        public async stt::Task ReplaceTaxonomyRequestObjectAsync()
        {
            moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient> mockGrpcClient = new moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient>(moq::MockBehavior.Strict);
            ReplaceTaxonomyRequest request = new ReplaceTaxonomyRequest
            {
                TaxonomyName       = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                SerializedTaxonomy = new SerializedTaxonomy(),
            };
            Taxonomy expectedResponse = new Taxonomy
            {
                TaxonomyName         = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                DisplayName          = "display_name137f65c2",
                Description          = "description2cf9da67",
                PolicyTagCount       = -1730676159,
                TaxonomyTimestamps   = new SystemTimestamps(),
                ActivatedPolicyTypes =
                {
                    Taxonomy.Types.PolicyType.Unspecified,
                },
            };

            mockGrpcClient.Setup(x => x.ReplaceTaxonomyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Taxonomy>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            PolicyTagManagerSerializationClient client = new PolicyTagManagerSerializationClientImpl(mockGrpcClient.Object, null);
            Taxonomy responseCallSettings = await client.ReplaceTaxonomyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Taxonomy responseCancellationToken = await client.ReplaceTaxonomyAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public async stt::Task ExportTaxonomiesRequestObjectAsync()
        {
            moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient> mockGrpcClient = new moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient>(moq::MockBehavior.Strict);
            ExportTaxonomiesRequest request = new ExportTaxonomiesRequest
            {
                ParentAsLocationName      = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                TaxonomiesAsTaxonomyNames =
                {
                    TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                },
                SerializedTaxonomies = true,
            };
            ExportTaxonomiesResponse expectedResponse = new ExportTaxonomiesResponse
            {
                Taxonomies =
                {
                    new SerializedTaxonomy(),
                },
            };

            mockGrpcClient.Setup(x => x.ExportTaxonomiesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ExportTaxonomiesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            PolicyTagManagerSerializationClient client = new PolicyTagManagerSerializationClientImpl(mockGrpcClient.Object, null);
            ExportTaxonomiesResponse            responseCallSettings = await client.ExportTaxonomiesAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ExportTaxonomiesResponse responseCancellationToken = await client.ExportTaxonomiesAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        public void ReplaceTaxonomyRequestObject()
        {
            moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient> mockGrpcClient = new moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient>(moq::MockBehavior.Strict);
            ReplaceTaxonomyRequest request = new ReplaceTaxonomyRequest
            {
                TaxonomyName       = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                SerializedTaxonomy = new SerializedTaxonomy(),
            };
            Taxonomy expectedResponse = new Taxonomy
            {
                TaxonomyName         = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                DisplayName          = "display_name137f65c2",
                Description          = "description2cf9da67",
                PolicyTagCount       = -1730676159,
                TaxonomyTimestamps   = new SystemTimestamps(),
                ActivatedPolicyTypes =
                {
                    Taxonomy.Types.PolicyType.Unspecified,
                },
            };

            mockGrpcClient.Setup(x => x.ReplaceTaxonomy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            PolicyTagManagerSerializationClient client = new PolicyTagManagerSerializationClientImpl(mockGrpcClient.Object, null);
            Taxonomy response = client.ReplaceTaxonomy(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 4
0
        public void ExportTaxonomiesRequestObject()
        {
            moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient> mockGrpcClient = new moq::Mock <PolicyTagManagerSerialization.PolicyTagManagerSerializationClient>(moq::MockBehavior.Strict);
            ExportTaxonomiesRequest request = new ExportTaxonomiesRequest
            {
                ParentAsLocationName      = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                TaxonomiesAsTaxonomyNames =
                {
                    TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                },
                SerializedTaxonomies = true,
            };
            ExportTaxonomiesResponse expectedResponse = new ExportTaxonomiesResponse
            {
                Taxonomies =
                {
                    new SerializedTaxonomy(),
                },
            };

            mockGrpcClient.Setup(x => x.ExportTaxonomies(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            PolicyTagManagerSerializationClient client   = new PolicyTagManagerSerializationClientImpl(mockGrpcClient.Object, null);
            ExportTaxonomiesResponse            response = client.ExportTaxonomies(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 5
0
 /// <summary>Snippet for GetTaxonomy</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetTaxonomyResourceNames()
 {
     // Create client
     PolicyTagManagerClient policyTagManagerClient = PolicyTagManagerClient.Create();
     // Initialize request argument(s)
     TaxonomyName name = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]");
     // Make the request
     Taxonomy response = policyTagManagerClient.GetTaxonomy(name);
 }
 /// <summary>Snippet for CreatePolicyTag</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreatePolicyTagResourceNames()
 {
     // Create client
     PolicyTagManagerClient policyTagManagerClient = PolicyTagManagerClient.Create();
     // Initialize request argument(s)
     TaxonomyName parent    = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]");
     PolicyTag    policyTag = new PolicyTag();
     // Make the request
     PolicyTag response = policyTagManagerClient.CreatePolicyTag(parent, policyTag);
 }
Esempio n. 7
0
        /// <summary>Snippet for DeleteTaxonomyAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task DeleteTaxonomyResourceNamesAsync()
        {
            // Create client
            PolicyTagManagerClient policyTagManagerClient = await PolicyTagManagerClient.CreateAsync();

            // Initialize request argument(s)
            TaxonomyName name = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]");
            // Make the request
            await policyTagManagerClient.DeleteTaxonomyAsync(name);
        }
 /// <summary>Snippet for GetTaxonomy</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetTaxonomyRequestObject()
 {
     // Create client
     PolicyTagManagerClient policyTagManagerClient = PolicyTagManagerClient.Create();
     // Initialize request argument(s)
     GetTaxonomyRequest request = new GetTaxonomyRequest
     {
         TaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
     };
     // Make the request
     Taxonomy response = policyTagManagerClient.GetTaxonomy(request);
 }
Esempio n. 9
0
 /// <summary>Snippet for CreatePolicyTag</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void CreatePolicyTagRequestObject()
 {
     // Create client
     PolicyTagManagerClient policyTagManagerClient = PolicyTagManagerClient.Create();
     // Initialize request argument(s)
     CreatePolicyTagRequest request = new CreatePolicyTagRequest
     {
         ParentAsTaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
         PolicyTag            = new PolicyTag(),
     };
     // Make the request
     PolicyTag response = policyTagManagerClient.CreatePolicyTag(request);
 }
Esempio n. 10
0
        /// <summary>Snippet for DeleteTaxonomyAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task DeleteTaxonomyRequestObjectAsync()
        {
            // Create client
            PolicyTagManagerClient policyTagManagerClient = await PolicyTagManagerClient.CreateAsync();

            // Initialize request argument(s)
            DeleteTaxonomyRequest request = new DeleteTaxonomyRequest
            {
                TaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
            };
            // Make the request
            await policyTagManagerClient.DeleteTaxonomyAsync(request);
        }
 /// <summary>Snippet for ReplaceTaxonomy</summary>
 public void ReplaceTaxonomyRequestObject()
 {
     // Snippet: ReplaceTaxonomy(ReplaceTaxonomyRequest, CallSettings)
     // Create client
     PolicyTagManagerSerializationClient policyTagManagerSerializationClient = PolicyTagManagerSerializationClient.Create();
     // Initialize request argument(s)
     ReplaceTaxonomyRequest request = new ReplaceTaxonomyRequest
     {
         TaxonomyName       = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
         SerializedTaxonomy = new SerializedTaxonomy(),
     };
     // Make the request
     Taxonomy response = policyTagManagerSerializationClient.ReplaceTaxonomy(request);
     // End snippet
 }
        /// <summary>Snippet for ListPolicyTagsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ListPolicyTagsRequestObjectAsync()
        {
            // Create client
            PolicyTagManagerClient policyTagManagerClient = await PolicyTagManagerClient.CreateAsync();

            // Initialize request argument(s)
            ListPolicyTagsRequest request = new ListPolicyTagsRequest
            {
                ParentAsTaxonomyName = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
            };
            // Make the request
            PagedAsyncEnumerable <ListPolicyTagsResponse, PolicyTag> response = policyTagManagerClient.ListPolicyTagsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((PolicyTag item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListPolicyTagsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (PolicyTag 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 <PolicyTag> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (PolicyTag 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;
        }
 /// <summary>Snippet for ExportTaxonomies</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void ExportTaxonomiesRequestObject()
 {
     // Create client
     PolicyTagManagerSerializationClient policyTagManagerSerializationClient = PolicyTagManagerSerializationClient.Create();
     // Initialize request argument(s)
     ExportTaxonomiesRequest request = new ExportTaxonomiesRequest
     {
         ParentAsLocationName      = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
         TaxonomiesAsTaxonomyNames =
         {
             TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
         },
         SerializedTaxonomies = false,
     };
     // Make the request
     ExportTaxonomiesResponse response = policyTagManagerSerializationClient.ExportTaxonomies(request);
 }
        /// <summary>Snippet for ReplaceTaxonomyAsync</summary>
        public async Task ReplaceTaxonomyRequestObjectAsync()
        {
            // Snippet: ReplaceTaxonomyAsync(ReplaceTaxonomyRequest, CallSettings)
            // Additional: ReplaceTaxonomyAsync(ReplaceTaxonomyRequest, CancellationToken)
            // Create client
            PolicyTagManagerSerializationClient policyTagManagerSerializationClient = await PolicyTagManagerSerializationClient.CreateAsync();

            // Initialize request argument(s)
            ReplaceTaxonomyRequest request = new ReplaceTaxonomyRequest
            {
                TaxonomyName       = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                SerializedTaxonomy = new SerializedTaxonomy(),
            };
            // Make the request
            Taxonomy response = await policyTagManagerSerializationClient.ReplaceTaxonomyAsync(request);

            // End snippet
        }
        /// <summary>Snippet for ListPolicyTags</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void ListPolicyTagsResourceNames()
        {
            // Create client
            PolicyTagManagerClient policyTagManagerClient = PolicyTagManagerClient.Create();
            // Initialize request argument(s)
            TaxonomyName parent = TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]");
            // Make the request
            PagedEnumerable <ListPolicyTagsResponse, PolicyTag> response = policyTagManagerClient.ListPolicyTags(parent);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (PolicyTag 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 (ListPolicyTagsResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (PolicyTag 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 <PolicyTag> 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 (PolicyTag 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;
        }
        /// <summary>Snippet for ExportTaxonomiesAsync</summary>
        public async Task ExportTaxonomiesRequestObjectAsync()
        {
            // Snippet: ExportTaxonomiesAsync(ExportTaxonomiesRequest, CallSettings)
            // Additional: ExportTaxonomiesAsync(ExportTaxonomiesRequest, CancellationToken)
            // Create client
            PolicyTagManagerSerializationClient policyTagManagerSerializationClient = await PolicyTagManagerSerializationClient.CreateAsync();

            // Initialize request argument(s)
            ExportTaxonomiesRequest request = new ExportTaxonomiesRequest
            {
                ParentAsLocationName      = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                TaxonomiesAsTaxonomyNames =
                {
                    TaxonomyName.FromProjectLocationTaxonomy("[PROJECT]", "[LOCATION]", "[TAXONOMY]"),
                },
                SerializedTaxonomies = false,
            };
            // Make the request
            ExportTaxonomiesResponse response = await policyTagManagerSerializationClient.ExportTaxonomiesAsync(request);

            // End snippet
        }