Search in sources :

Example 1 with Binding

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]
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) TopicAdminClient(com.google.cloud.pubsub.spi.v1.TopicAdminClient)

Example 2 with Binding

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);
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) ByteString(com.google.protobuf.ByteString) TopicName(com.google.pubsub.v1.TopicName) Test(org.junit.Test)

Example 3 with Binding

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]
}
Also used : Policy(com.google.iam.v1.Policy) Binding(com.google.iam.v1.Binding) SubscriptionAdminClient(com.google.cloud.pubsub.spi.v1.SubscriptionAdminClient) SubscriptionName(com.google.pubsub.v1.SubscriptionName)

Example 4 with Binding

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;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)

Example 5 with Binding

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;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) Invocation(org.kie.workbench.common.dmn.api.definition.v1_1.Invocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Aggregations

Binding (com.google.iam.v1.Binding)6 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)6 Policy (com.google.iam.v1.Policy)4 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)4 Invocation (org.kie.workbench.common.dmn.api.definition.v1_1.Invocation)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)3 TopicName (com.google.pubsub.v1.TopicName)2 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)2 GoogleCredential (com.google.api.client.googleapis.auth.oauth2.GoogleCredential)1 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)1 JsonFactory (com.google.api.client.json.JsonFactory)1 CloudIot (com.google.api.services.cloudiot.v1.CloudIot)1 GetIamPolicyRequest (com.google.api.services.cloudiot.v1.model.GetIamPolicyRequest)1 SetIamPolicyRequest (com.google.api.services.cloudiot.v1.model.SetIamPolicyRequest)1 SubscriptionAdminClient (com.google.cloud.pubsub.spi.v1.SubscriptionAdminClient)1 TopicAdminClient (com.google.cloud.pubsub.spi.v1.TopicAdminClient)1 TopicAdminClient (com.google.cloud.pubsub.v1.TopicAdminClient)1 SecurityCenterClient (com.google.cloud.securitycenter.v1.SecurityCenterClient)1 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)1