Beispiel #1
0
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsAsync_RequestObject()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsRequest,CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsRequest,CancellationToken)
            // Create client
            DatabaseAdminClient databaseAdminClient = await DatabaseAdminClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new DatabaseName("[PROJECT]", "[INSTANCE]", "[DATABASE]").ToString(),
                Permissions = { },
            };
            // Make the request
            TestIamPermissionsResponse response = await databaseAdminClient.TestIamPermissionsAsync(request);

            // End snippet
        }
Beispiel #2
0
        public TestIamPermissionsResponse TestSubscriptionIamPermissionsResponse(
            string subscriptionId, PublisherServiceApiClient publisher)
        {
            // [START pubsub_test_subscription_permissons]
            List <string> permissions = new List <string>();

            permissions.Add("pubsub.subscriptions.get");
            permissions.Add("pubsub.subscriptions.update");
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new SubscriptionName(_projectId, subscriptionId).ToString(),
                Permissions = { permissions }
            };
            TestIamPermissionsResponse response = publisher.TestIamPermissions(request);

            return(response);
            // [END pubsub_test_subscription_permissons]
        }
Beispiel #3
0
        public void TestIamPermissions2()
        {
            Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict);
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Permissions            = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissions(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ContainerAnalysisClient    client   = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            TestIamPermissionsResponse response = client.TestIamPermissions(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #4
0
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsRequestObjectAsync()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsRequest, CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsRequest, CancellationToken)
            // Create client
            CloudFunctionsServiceClient cloudFunctionsServiceClient = await CloudFunctionsServiceClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                ResourceAsResourceName = new UnparsedResourceName("a/wildcard/resource"),
                Permissions            = { "", },
            };
            // Make the request
            TestIamPermissionsResponse response = await cloudFunctionsServiceClient.TestIamPermissionsAsync(request);

            // End snippet
        }
        public TestIamPermissionsResponse TestTopicIamPermissionsResponse(string topicId,
                                                                          PublisherClient publisher)
        {
            // [START pubsub_test_topic_permissons]
            List <string> permissions = new List <string>();

            permissions.Add("pubsub.topics.get");
            permissions.Add("pubsub.topics.update");
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new TopicName(_projectId, topicId).ToString(),
                Permissions = { permissions }
            };
            TestIamPermissionsResponse response = publisher.TestIamPermissions(request);

            return(response);
            // [END pubsub_test_topic_permissons]
        }
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsAsync_RequestObject()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsRequest,CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsRequest,CancellationToken)
            // Create client
            PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new TopicName("[PROJECT]", "[TOPIC]").ToString(),
                Permissions = { },
            };
            // Make the request
            TestIamPermissionsResponse response = await publisherServiceApiClient.TestIamPermissionsAsync(request);

            // End snippet
        }
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsAsync_RequestObject()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsRequest,CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsRequest,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString(),
                Permissions = { },
            };
            // Make the request
            TestIamPermissionsResponse response = await bigtableTableAdminClient.TestIamPermissionsAsync(request);

            // End snippet
        }
Beispiel #8
0
        public async Task TestIamPermissionsAsync2()
        {
            Mock <ContainerAnalysisV1Beta1.ContainerAnalysisV1Beta1Client> mockGrpcClient = new Mock <ContainerAnalysisV1Beta1.ContainerAnalysisV1Beta1Client>(MockBehavior.Strict);
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                ResourceAsIamResourceNameOneof = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TestIamPermissionsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisV1Beta1Client client   = new ContainerAnalysisV1Beta1ClientImpl(mockGrpcClient.Object, null);
            TestIamPermissionsResponse     response = await client.TestIamPermissionsAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #9
0
        /// <summary>Snippet for TestIamPermissionsAsync</summary>
        public async Task TestIamPermissionsAsync_RequestObject()
        {
            // Snippet: TestIamPermissionsAsync(TestIamPermissionsRequest,CallSettings)
            // Additional: TestIamPermissionsAsync(TestIamPermissionsRequest,CancellationToken)
            // Create client
            ContainerAnalysisClient containerAnalysisClient = await ContainerAnalysisClient.CreateAsync();

            // Initialize request argument(s)
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Permissions            = { },
            };
            // Make the request
            TestIamPermissionsResponse response = await containerAnalysisClient.TestIamPermissionsAsync(request);

            // End snippet
        }
Beispiel #10
0
        public async Task TestIamPermissionsAsync2()
        {
            Mock <BigtableTableAdmin.BigtableTableAdminClient> mockGrpcClient = new Mock <BigtableTableAdmin.BigtableTableAdminClient>(MockBehavior.Strict);
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString(),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TestIamPermissionsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            BigtableTableAdminClient   client   = new BigtableTableAdminClientImpl(mockGrpcClient.Object, null);
            TestIamPermissionsResponse response = await client.TestIamPermissionsAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #11
0
        public void TestIamPermissions()
        {
            Mock <BigtableTableAdmin.BigtableTableAdminClient> mockGrpcClient = new Mock <BigtableTableAdmin.BigtableTableAdminClient>(MockBehavior.Strict);
            TestIamPermissionsRequest expectedRequest = new TestIamPermissionsRequest
            {
                Resource    = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString(),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissions(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            BigtableTableAdminClient client        = new BigtableTableAdminClientImpl(mockGrpcClient.Object, null);
            string formattedResource               = new Google.Cloud.Bigtable.Common.V2.TableName("[PROJECT]", "[INSTANCE]", "[TABLE]").ToString();
            IEnumerable <string>       permissions = new List <string>();
            TestIamPermissionsResponse response    = client.TestIamPermissions(formattedResource, permissions);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #12
0
    public static IList <String> TestIamPermissions(string projectId)
    {
        var credential = GoogleCredential.GetApplicationDefault()
                         .CreateScoped(CloudResourceManagerService.Scope.CloudPlatform);
        var service = new CloudResourceManagerService(
            new CloudResourceManagerService.Initializer
        {
            HttpClientInitializer = credential
        });

        TestIamPermissionsRequest requestBody = new TestIamPermissionsRequest();
        var permissions = new List <string>()
        {
            "resourcemanager.projects.get", "resourcemanager.projects.delete"
        };

        requestBody.Permissions = new List <string>(permissions);
        var returnedPermissions = service.Projects.TestIamPermissions(requestBody, projectId).Execute().Permissions;

        return(returnedPermissions);
    }
Beispiel #13
0
        public async Task TestIamPermissionsAsync2()
        {
            Mock <InstanceAdmin.InstanceAdminClient> mockGrpcClient = new Mock <InstanceAdmin.InstanceAdminClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new InstanceName("[PROJECT]", "[INSTANCE]").ToString(),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TestIamPermissionsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            InstanceAdminClient        client   = new InstanceAdminClientImpl(mockGrpcClient.Object, null);
            TestIamPermissionsResponse response = await client.TestIamPermissionsAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #14
0
        public void TestIamPermissions2()
        {
            Mock <InstanceAdmin.InstanceAdminClient> mockGrpcClient = new Mock <InstanceAdmin.InstanceAdminClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                Resource    = new InstanceName("[PROJECT]", "[INSTANCE]").ToString(),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissions(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            InstanceAdminClient        client   = new InstanceAdminClientImpl(mockGrpcClient.Object, null);
            TestIamPermissionsResponse response = client.TestIamPermissions(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #15
0
        public async Task TestIamPermissionsAsync()
        {
            Mock <DatabaseAdmin.DatabaseAdminClient> mockGrpcClient = new Mock <DatabaseAdmin.DatabaseAdminClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            TestIamPermissionsRequest expectedRequest = new TestIamPermissionsRequest
            {
                Resource    = new Google.Cloud.Spanner.Common.V1.DatabaseName("[PROJECT]", "[INSTANCE]", "[DATABASE]").ToString(),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TestIamPermissionsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            DatabaseAdminClient client             = new DatabaseAdminClientImpl(mockGrpcClient.Object, null);
            string formattedResource               = new Google.Cloud.Spanner.Common.V1.DatabaseName("[PROJECT]", "[INSTANCE]", "[DATABASE]").ToString();
            IEnumerable <string>       permissions = new List <string>();
            TestIamPermissionsResponse response    = await client.TestIamPermissionsAsync(formattedResource, permissions);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void TestIamPermissions()
        {
            Mock <DatabaseAdmin.DatabaseAdminClient> mockGrpcClient = new Mock <DatabaseAdmin.DatabaseAdminClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            TestIamPermissionsRequest expectedRequest = new TestIamPermissionsRequest
            {
                Resource    = new DatabaseName("[PROJECT]", "[INSTANCE]", "[DATABASE]").ToString(),
                Permissions = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissions(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            DatabaseAdminClient client             = new DatabaseAdminClientImpl(mockGrpcClient.Object, null);
            string formattedResource               = new DatabaseName("[PROJECT]", "[INSTANCE]", "[DATABASE]").ToString();
            IEnumerable <string>       permissions = new List <string>();
            TestIamPermissionsResponse response    = client.TestIamPermissions(formattedResource, permissions);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #17
0
        /// <summary>
        /// Returns permissions that a caller has on the specified resource.See <a href="/iam/docs/managing-policies#testing_permissions">TestingPermissions</a> for more information.For the definitions of datasets and other genomics resources, see[Fundamentals of GoogleGenomics](https://cloud.google.com/genomics/fundamentals-of-google-genomics)
        /// Documentation https://developers.google.com/genomics/v1/reference/datasets/testIamPermissions
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Genomics service.</param>
        /// <param name="resource">REQUIRED: The resource for which policy is being specified. Format is`datasets/<dataset ID>`.</param>
        /// <param name="body">A valid Genomics v1 body.</param>
        /// <returns>TestIamPermissionsResponseResponse</returns>
        public static TestIamPermissionsResponse TestIamPermissions(GenomicsService service, string resource, TestIamPermissionsRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (resource == null)
                {
                    throw new ArgumentNullException(resource);
                }

                // Make the request.
                return(service.Datasets.TestIamPermissions(body, resource).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Datasets.TestIamPermissions failed.", ex);
            }
        }
 internal void ModifyRequest(TestIamPermissionsRequest request)
 {
 }
Beispiel #19
0
 partial void Modify_TestIamPermissionsRequest(ref TestIamPermissionsRequest request, ref CallSettings settings) =>
 ApplyResourcePrefixHeader(ref settings, request.Resource);