use of org.kie.workbench.common.dmn.api.definition.v1_1.Binding in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientSnippets method replaceTopicPolicy.
/** Example of replacing a topic policy. */
public Policy replaceTopicPolicy(String topicId) throws Exception {
// [START pubsub_set_topic_policy]
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
String topicName = TopicName.create(projectId, topicId).toString();
Policy policy = topicAdminClient.getIamPolicy(topicName);
// add role -> members binding
Binding binding = Binding.newBuilder().setRole(Role.viewer().toString()).addMembers(Identity.allAuthenticatedUsers().toString()).build();
// create updated policy
Policy updatedPolicy = Policy.newBuilder(policy).addBindings(binding).build();
updatedPolicy = topicAdminClient.setIamPolicy(topicName, updatedPolicy);
return updatedPolicy;
}
// [END pubsub_set_topic_policy]
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Binding in project google-cloud-java by GoogleCloudPlatform.
the class ITPubSubTest method testTopicPolicy.
@Test
public void testTopicPolicy() {
TopicName topicName = TopicName.create(projectId, formatForTest("testing-topic-policy"));
topicAdminClient.createTopic(topicName);
Policy policy = topicAdminClient.getIamPolicy(topicName.toString());
Binding binding = Binding.newBuilder().setRole("roles/viewer").addMembers("allAuthenticatedUsers").build();
Policy newPolicy = topicAdminClient.setIamPolicy(topicName.toString(), policy.toBuilder().addBindings(binding).build());
assertTrue(newPolicy.getBindingsList().contains(binding));
String permissionName = "pubsub.topics.get";
List<String> permissions = topicAdminClient.testIamPermissions(topicName.toString(), Collections.singletonList(permissionName)).getPermissionsList();
assertTrue(permissions.contains(permissionName));
topicAdminClient.deleteTopic(topicName);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Binding in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientSnippets method replaceSubscriptionPolicy.
/** Example of replacing a subscription policy. */
public Policy replaceSubscriptionPolicy(String subscriptionId) throws Exception {
// [START pubsub_set_subscription_policy]
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
Policy policy = subscriptionAdminClient.getIamPolicy(subscriptionName.toString());
// Create a role => members binding
Binding binding = Binding.newBuilder().setRole(Role.viewer().toString()).addMembers(Identity.allAuthenticatedUsers().toString()).build();
//Update policy
Policy updatedPolicy = policy.toBuilder().addBindings(binding).build();
updatedPolicy = subscriptionAdminClient.setIamPolicy(subscriptionName.toString(), updatedPolicy);
return updatedPolicy;
}
// [END pubsub_set_subscription_policy]
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Binding in project kie-wb-common by kiegroup.
the class BindingPropertyConverter method wbFromDMN.
public static Binding wbFromDMN(final org.kie.dmn.model.v1_1.Binding dmn) {
if (dmn == null) {
return null;
}
InformationItem convertedParameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
Expression convertedExpression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression());
Binding result = new Binding();
result.setParameter(convertedParameter);
result.setExpression(convertedExpression);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.Binding in project kie-wb-common by kiegroup.
the class InvocationUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
doReturn(uiModel).when(gridWidget).getModel();
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
final LiteralExpression invocationExpression = new LiteralExpression();
invocationExpression.setText("invocation-expression");
final LiteralExpression bindingExpression = new LiteralExpression();
bindingExpression.setText("binding-expression");
final Binding binding = new Binding();
final InformationItem parameter = new InformationItem();
parameter.setName(new Name("p0"));
binding.setParameter(parameter);
binding.setExpression(bindingExpression);
this.invocation = new Invocation();
this.invocation.setExpression(invocationExpression);
this.invocation.getBinding().add(binding);
this.mapper = new InvocationUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(invocation), expressionEditorDefinitionsSupplier, listSelector, 0);
this.cellValueSupplier = Optional::empty;
}
Aggregations