Search in sources :

Example 26 with Binding

use of org.flyte.api.v1.Binding in project java-pubsub by googleapis.

the class TopicAdminClientTest method getIamPolicyTest.

@Test
public void getIamPolicyTest() throws Exception {
    Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
    mockIAMPolicy.addResponse(expectedResponse);
    GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(ProjectName.of("[PROJECT]").toString()).setOptions(GetPolicyOptions.newBuilder().build()).build();
    Policy actualResponse = client.getIamPolicy(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockIAMPolicy.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(request.getResource(), actualRequest.getResource());
    Assert.assertEquals(request.getOptions(), actualRequest.getOptions());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Policy(com.google.iam.v1.Policy) MessageStoragePolicy(com.google.pubsub.v1.MessageStoragePolicy) Binding(com.google.iam.v1.Binding) AbstractMessage(com.google.protobuf.AbstractMessage) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) Test(org.junit.Test)

Example 27 with Binding

use of org.flyte.api.v1.Binding in project java-pubsub by googleapis.

the class SetTopicPolicyExample method setTopicPolicyExample.

public static void setTopicPolicyExample(String projectId, String topicId) throws IOException {
    try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
        TopicName topicName = TopicName.of(projectId, topicId);
        GetIamPolicyRequest getIamPolicyRequest = GetIamPolicyRequest.newBuilder().setResource(topicName.toString()).build();
        Policy oldPolicy = topicAdminClient.getIamPolicy(getIamPolicyRequest);
        // Create new role -> members binding
        Binding binding = Binding.newBuilder().setRole("roles/pubsub.editor").addMembers("allUsers").build();
        // Add new binding to updated policy
        Policy updatedPolicy = Policy.newBuilder(oldPolicy).addBindings(binding).build();
        SetIamPolicyRequest setIamPolicyRequest = SetIamPolicyRequest.newBuilder().setResource(topicName.toString()).setPolicy(updatedPolicy).build();
        Policy newPolicy = topicAdminClient.setIamPolicy(setIamPolicyRequest);
        System.out.println("New topic policy: " + newPolicy);
    }
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) TopicAdminClient(com.google.cloud.pubsub.v1.TopicAdminClient) SetIamPolicyRequest(com.google.iam.v1.SetIamPolicyRequest) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) TopicName(com.google.pubsub.v1.TopicName)

Example 28 with Binding

use of org.flyte.api.v1.Binding in project java-spanner by googleapis.

the class InstanceAdminClientTest method setIamPolicyTest2.

@Test
public void setIamPolicyTest2() throws Exception {
    Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
    mockInstanceAdmin.addResponse(expectedResponse);
    String resource = "resource-341064690";
    Policy policy = Policy.newBuilder().build();
    Policy actualResponse = client.setIamPolicy(resource, policy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(resource, actualRequest.getResource());
    Assert.assertEquals(policy, actualRequest.getPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) AbstractMessage(com.google.protobuf.AbstractMessage) SetIamPolicyRequest(com.google.iam.v1.SetIamPolicyRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 29 with Binding

use of org.flyte.api.v1.Binding in project java-spanner by googleapis.

the class InstanceAdminClientTest method setIamPolicyTest.

@Test
public void setIamPolicyTest() throws Exception {
    Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
    mockInstanceAdmin.addResponse(expectedResponse);
    ResourceName resource = ProjectName.of("[PROJECT]");
    Policy policy = Policy.newBuilder().build();
    Policy actualResponse = client.setIamPolicy(resource, policy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(resource.toString(), actualRequest.getResource());
    Assert.assertEquals(policy, actualRequest.getPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) AbstractMessage(com.google.protobuf.AbstractMessage) SetIamPolicyRequest(com.google.iam.v1.SetIamPolicyRequest) ResourceName(com.google.api.resourcenames.ResourceName) Test(org.junit.Test)

Example 30 with Binding

use of org.flyte.api.v1.Binding in project java-spanner by googleapis.

the class DatabaseAdminClientTest method setIamPolicyTest.

@Test
public void setIamPolicyTest() throws Exception {
    Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
    mockDatabaseAdmin.addResponse(expectedResponse);
    ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
    Policy policy = Policy.newBuilder().build();
    Policy actualResponse = client.setIamPolicy(resource, policy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(resource.toString(), actualRequest.getResource());
    Assert.assertEquals(policy, actualRequest.getPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) AbstractMessage(com.google.protobuf.AbstractMessage) SetIamPolicyRequest(com.google.iam.v1.SetIamPolicyRequest) ResourceName(com.google.api.resourcenames.ResourceName) Test(org.junit.Test)

Aggregations

Binding (com.google.iam.v1.Binding)104 Policy (com.google.iam.v1.Policy)101 Test (org.junit.Test)87 AbstractMessage (com.google.protobuf.AbstractMessage)82 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)47 GetIamPolicyRequest (com.google.iam.v1.GetIamPolicyRequest)43 ResourceName (com.google.api.resourcenames.ResourceName)32 ByteString (com.google.protobuf.ByteString)32 Node (org.flyte.api.v1.Node)8 CryptoKeyName (com.google.cloud.kms.v1.CryptoKeyName)6 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)6 MockIAMPolicy (com.google.iam.v1.MockIAMPolicy)6 TaskNode (org.flyte.api.v1.TaskNode)6 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)6 Test (org.junit.jupiter.api.Test)5 SecretManagerServiceClient (com.google.cloud.secretmanager.v1.SecretManagerServiceClient)4 SecretName (com.google.cloud.secretmanager.v1.SecretName)4 ArrayList (java.util.ArrayList)4 Binding (org.flyte.api.v1.Binding)4 WorkflowTemplate (org.flyte.api.v1.WorkflowTemplate)4