use of org.flyte.api.v1.Binding in project java-bigqueryconnection by googleapis.
the class ITSystemTest method testShareConnection.
@Test
public void testShareConnection() {
ResourceName resource = ConnectionName.of(PROJECT_ID, LOCATION, CONNECTION_ID);
Binding binding = Binding.newBuilder().addMembers("group:example-analyst-group@google.com").setRole("roles/bigquery.connectionUser").build();
Policy policy = Policy.newBuilder().addBindings(binding).build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder().setResource(resource.toString()).setPolicy(policy).build();
Policy actualPolicy = client.setIamPolicy(request);
assertEquals(ImmutableList.of(binding), actualPolicy.getBindingsList());
}
use of org.flyte.api.v1.Binding in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method setIamPolicyTest2.
@Test
public void setIamPolicyTest2() throws Exception {
Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
mockConnectionService.addResponse(expectedResponse);
String resource = "resource-341064690";
Policy policy = Policy.newBuilder().build();
Policy actualResponse = client.setIamPolicy(resource, policy);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConnectionService.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()));
}
use of org.flyte.api.v1.Binding in project java-bigqueryconnection by googleapis.
the class ConnectionServiceClientTest method getIamPolicyTest.
@Test
public void getIamPolicyTest() throws Exception {
Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
mockConnectionService.addResponse(expectedResponse);
ResourceName resource = ConnectionName.of("[PROJECT]", "[LOCATION]", "[CONNECTION]");
GetPolicyOptions options = GetPolicyOptions.newBuilder().build();
Policy actualResponse = client.getIamPolicy(resource, options);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConnectionService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
Assert.assertEquals(resource.toString(), actualRequest.getResource());
Assert.assertEquals(options, actualRequest.getOptions());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.flyte.api.v1.Binding in project java-bigqueryconnection by googleapis.
the class ShareConnection method shareConnection.
public static void shareConnection(String projectId, String location, String connectionId) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
ResourceName resource = ConnectionName.of(projectId, location, connectionId);
Binding binding = Binding.newBuilder().addMembers("group:example-analyst-group@google.com").setRole("roles/bigquery.connectionUser").build();
Policy policy = Policy.newBuilder().addBindings(binding).build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder().setResource(resource.toString()).setPolicy(policy).build();
client.setIamPolicy(request);
System.out.println("Connection shared successfully");
}
}
use of org.flyte.api.v1.Binding in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest 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()));
}
Aggregations