use of com.google.api.services.actions_fulfillment.v2.model.Action in project be5 by DevelopmentOnTheEdge.
the class ResponseTest method sendAsRawJson.
// @Test
// public void sendErrorsAsJson() throws Exception {
// Action call = new Action("call", "test/path");
// response.sendErrorsAsJson(call);
//
// verify(writer).append(doubleQuotes("{'value':{'arg':'test/path','name':'call'}}"));
// verify(writer).flush();
// }
@Test
public void sendAsRawJson() {
Action call = new Action("call", "test/path");
response.sendAsRawJson(call);
verify(writer).append(doubleQuotes("{'arg':'test/path','name':'call'}"));
}
use of com.google.api.services.actions_fulfillment.v2.model.Action in project be5 by DevelopmentOnTheEdge.
the class Menu method collectEntityContent.
private void collectEntityContent(Entity entity, String language, Meta meta, UserAwareMeta userAwareMeta, List<String> roles, boolean withIds, List<RootNode> out) {
List<Query> permittedQueries = meta.getQueries(entity, roles);
if (permittedQueries.isEmpty()) {
return;
}
String title = meta.getTitle(entity, language);
List<OperationNode> operations = generateEntityOperations(entity, meta, userAwareMeta, roles, withIds);
if (operations.isEmpty()) {
operations = null;
}
if (canBeMovedToRoot(permittedQueries, title, language, meta)) {
// Query in the root, contains an action.
Id id = null;
Action action = ActionUtils.toAction(permittedQueries.get(0));
boolean isDefault = permittedQueries.get(0).isDefaultView();
if (withIds) {
String queryTitle = getTitleOfRootQuery(permittedQueries, title, language, meta);
id = new Id(entity.getName(), queryTitle);
}
out.add(RootNode.action(id, title, isDefault, action, operations));
} else {
// No query in the root, just inner queries.
List<QueryNode> children = generateEntityQueries(permittedQueries, language, meta, withIds);
Id id = new Id(entity.getName(), null);
out.add(RootNode.container(id, title, children, operations));
}
}
use of com.google.api.services.actions_fulfillment.v2.model.Action in project be5 by DevelopmentOnTheEdge.
the class DocumentGeneratorImpl method presentOperation.
private TableOperationPresentation presentOperation(Query query, Operation operation) {
String visibleWhen = Operations.determineWhenVisible(operation);
String title = userAwareMeta.getLocalizedOperationTitle(query.getEntity().getName(), operation.getName());
// boolean requiresConfirmation = operation.isConfirm();
boolean isClientSide = Operations.isClientSide(operation);
Action action = null;
if (isClientSide) {
action = Action.call(Operations.asClientSide(operation).toHashUrl());
}
return new TableOperationPresentation(operation.getName(), title, visibleWhen, false, isClientSide, action);
}
use of com.google.api.services.actions_fulfillment.v2.model.Action in project cloudbreak by hortonworks.
the class AwsNativeLoadBalancerLaunchService method createListener.
private void createListener(ResourceCreationContext context, AwsListener listener) {
CloudResource listenerResource;
Optional<CloudResource> existingLoadBalancer = persistenceRetriever.retrieveFirstByTypeAndStatusForStack(ResourceType.ELASTIC_LOAD_BALANCER_LISTENER, CommonStatus.CREATED, context.getStackId());
if (existingLoadBalancer.isPresent()) {
listenerResource = existingLoadBalancer.get();
LOGGER.info("Elastic load balancer listener resource has already been created for stack proceeding forward with existing resource '{}'", listenerResource.getReference());
} else {
String loadBalancerArn = context.getLoadBalancerArn();
String targetGroupArn = context.getTargetGroupArn();
LOGGER.info("Creating listener for load balancer('{}') on target group('{}')", loadBalancerArn, targetGroupArn);
Action defaultAction = new Action().withType(ActionTypeEnum.Forward).withOrder(1).withTargetGroupArn(targetGroupArn);
CreateListenerRequest listenerRequest = new CreateListenerRequest().withLoadBalancerArn(loadBalancerArn).withProtocol(ProtocolEnum.TCP).withPort(listener.getPort()).withDefaultActions(defaultAction).withTags(context.getTags());
CreateListenerResult registerListenerResult = createOrGetListener(context, listenerRequest);
String listenerArn = registerListenerResult.getListeners().stream().findFirst().orElseThrow().getListenerArn();
listenerResource = new CloudResource.Builder().name(context.getTargetGroupName()).type(ResourceType.ELASTIC_LOAD_BALANCER_LISTENER).reference(listenerArn).status(CommonStatus.CREATED).instanceId(loadBalancerArn).build();
context.getPersistenceNotifier().notifyAllocation(listenerResource, context.getCloudContext());
}
CloudResourceStatus cloudResourceStatus = new CloudResourceStatus(listenerResource, ResourceStatus.CREATED);
context.addResourceStatus(cloudResourceStatus);
}
use of com.google.api.services.actions_fulfillment.v2.model.Action in project be5 by DevelopmentOnTheEdge.
the class Menu method generateEntityOperations.
private List<OperationNode> generateEntityOperations(Entity entity, Meta meta, UserAwareMeta userAwareMeta, List<String> roles, boolean withIds) {
List<OperationNode> operations = new ArrayList<>();
Query allRecords = entity.getQueries().get(DatabaseConstants.ALL_RECORDS_VIEW);
String insertOperationName = INSERT_OPERATION;
if (allRecords != null && allRecords.getOperationNames().getFinalValues().contains(insertOperationName)) {
Operation insertOperation = entity.getOperations().get(insertOperationName);
if (insertOperation != null && meta.isAvailableFor(insertOperation, roles)) {
String title = userAwareMeta.getLocalizedOperationTitle(entity.getName(), insertOperationName);
Action action = ActionUtils.toAction(DatabaseConstants.ALL_RECORDS_VIEW, insertOperation);
OperationId id = withIds ? new OperationId(entity.getName(), insertOperationName) : null;
OperationNode operation = new OperationNode(id, title, action);
operations.add(operation);
}
}
return operations;
}
Aggregations