Search in sources :

Example 1 with Subscription

use of io.gravitee.management.rest.model.Subscription in project gravitee-management-rest-api by gravitee-io.

the class ApplicationSubscriptionsResource method createSubscription.

@POST
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Subscribe to a plan", notes = "User must have the MANAGE_SUBSCRIPTIONS permission to use this service")
@ApiResponses({ @ApiResponse(code = 201, message = "Subscription successfully created", response = Subscription.class), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.APPLICATION_SUBSCRIPTION, acls = RolePermissionAction.CREATE) })
public Response createSubscription(@PathParam("application") String application, @ApiParam(name = "plan", required = true) @NotNull @QueryParam("plan") String plan, NewSubscriptionEntity newSubscriptionEntity) {
    newSubscriptionEntity.setApplication(application);
    newSubscriptionEntity.setPlan(plan);
    Subscription subscription = convert(subscriptionService.create(newSubscriptionEntity));
    return Response.created(URI.create("/applications/" + application + "/subscriptions/" + subscription.getId())).entity(subscription).build();
}
Also used : Subscription(io.gravitee.management.rest.model.Subscription) Permissions(io.gravitee.management.rest.security.Permissions)

Example 2 with Subscription

use of io.gravitee.management.rest.model.Subscription in project gravitee-management-rest-api by gravitee-io.

the class SubscriptionsResource method convert.

private Subscription convert(SubscriptionEntity subscriptionEntity) {
    Subscription subscription = new Subscription();
    subscription.setId(subscriptionEntity.getId());
    subscription.setCreatedAt(subscriptionEntity.getCreatedAt());
    subscription.setUpdatedAt(subscriptionEntity.getUpdatedAt());
    subscription.setStartingAt(subscriptionEntity.getStartingAt());
    subscription.setEndingAt(subscriptionEntity.getEndingAt());
    subscription.setProcessedAt(subscriptionEntity.getProcessedAt());
    subscription.setProcessedBy(subscriptionEntity.getProcessedBy());
    subscription.setReason(subscriptionEntity.getReason());
    subscription.setStatus(subscriptionEntity.getStatus());
    ApplicationEntity application = applicationService.findById(subscriptionEntity.getApplication());
    subscription.setApplication(new Subscription.Application(application.getId(), application.getName(), application.getType(), new Subscription.User(application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName())));
    PlanEntity plan = planService.findById(subscriptionEntity.getPlan());
    subscription.setPlan(new Subscription.Plan(plan.getId(), plan.getName()));
    subscription.setClosedAt(subscriptionEntity.getClosedAt());
    return subscription;
}
Also used : ApplicationEntity(io.gravitee.management.model.ApplicationEntity) PlanEntity(io.gravitee.management.model.PlanEntity) Subscription(io.gravitee.management.rest.model.Subscription)

Example 3 with Subscription

use of io.gravitee.management.rest.model.Subscription in project gravitee-management-rest-api by gravitee-io.

the class ApiSubscriptionResource method convert.

private Subscription convert(SubscriptionEntity subscriptionEntity) {
    Subscription subscription = new Subscription();
    subscription.setId(subscriptionEntity.getId());
    subscription.setCreatedAt(subscriptionEntity.getCreatedAt());
    subscription.setUpdatedAt(subscriptionEntity.getUpdatedAt());
    subscription.setStartingAt(subscriptionEntity.getStartingAt());
    subscription.setEndingAt(subscriptionEntity.getEndingAt());
    subscription.setProcessedAt(subscriptionEntity.getProcessedAt());
    subscription.setProcessedBy(subscriptionEntity.getProcessedBy());
    subscription.setRequest(subscriptionEntity.getRequest());
    subscription.setReason(subscriptionEntity.getReason());
    subscription.setStatus(subscriptionEntity.getStatus());
    subscription.setSubscribedBy(new Subscription.User(subscriptionEntity.getSubscribedBy(), userService.findById(subscriptionEntity.getSubscribedBy()).getDisplayName()));
    subscription.setClientId(subscriptionEntity.getClientId());
    PlanEntity plan = planService.findById(subscriptionEntity.getPlan());
    subscription.setPlan(new Subscription.Plan(plan.getId(), plan.getName()));
    subscription.getPlan().setSecurity(plan.getSecurity());
    ApplicationEntity application = applicationService.findById(subscriptionEntity.getApplication());
    subscription.setApplication(new Subscription.Application(application.getId(), application.getName(), application.getType(), new Subscription.User(application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName())));
    subscription.setClosedAt(subscriptionEntity.getClosedAt());
    return subscription;
}
Also used : Subscription(io.gravitee.management.rest.model.Subscription)

Example 4 with Subscription

use of io.gravitee.management.rest.model.Subscription in project gravitee-management-rest-api by gravitee-io.

the class ApiSubscriptionsResource method convert.

private Subscription convert(SubscriptionEntity subscriptionEntity) {
    Subscription subscription = new Subscription();
    subscription.setId(subscriptionEntity.getId());
    subscription.setCreatedAt(subscriptionEntity.getCreatedAt());
    subscription.setUpdatedAt(subscriptionEntity.getUpdatedAt());
    subscription.setStartingAt(subscriptionEntity.getStartingAt());
    subscription.setEndingAt(subscriptionEntity.getEndingAt());
    subscription.setProcessedAt(subscriptionEntity.getProcessedAt());
    subscription.setProcessedBy(subscriptionEntity.getProcessedBy());
    subscription.setReason(subscriptionEntity.getReason());
    subscription.setStatus(subscriptionEntity.getStatus());
    subscription.setSubscribedBy(new Subscription.User(subscriptionEntity.getSubscribedBy(), userService.findById(subscriptionEntity.getSubscribedBy()).getDisplayName()));
    PlanEntity plan = planService.findById(subscriptionEntity.getPlan());
    subscription.setPlan(new Subscription.Plan(plan.getId(), plan.getName()));
    ApplicationEntity application = applicationService.findById(subscriptionEntity.getApplication());
    subscription.setApplication(new Subscription.Application(application.getId(), application.getName(), application.getType(), new Subscription.User(application.getPrimaryOwner().getId(), application.getPrimaryOwner().getDisplayName())));
    subscription.setClosedAt(subscriptionEntity.getClosedAt());
    return subscription;
}
Also used : Subscription(io.gravitee.management.rest.model.Subscription)

Example 5 with Subscription

use of io.gravitee.management.rest.model.Subscription in project gravitee-management-rest-api by gravitee-io.

the class ApplicationSubscriptionsResource method convert.

private Subscription convert(SubscriptionEntity subscriptionEntity) {
    Subscription subscription = new Subscription();
    subscription.setId(subscriptionEntity.getId());
    subscription.setCreatedAt(subscriptionEntity.getCreatedAt());
    subscription.setUpdatedAt(subscriptionEntity.getUpdatedAt());
    subscription.setStartingAt(subscriptionEntity.getStartingAt());
    subscription.setEndingAt(subscriptionEntity.getEndingAt());
    subscription.setProcessedAt(subscriptionEntity.getProcessedAt());
    subscription.setProcessedBy(subscriptionEntity.getProcessedBy());
    subscription.setReason(subscriptionEntity.getReason());
    subscription.setRequest(subscriptionEntity.getRequest());
    subscription.setStatus(subscriptionEntity.getStatus());
    subscription.setSubscribedBy(new Subscription.User(subscriptionEntity.getSubscribedBy(), userService.findById(subscriptionEntity.getSubscribedBy()).getDisplayName()));
    PlanEntity plan = planService.findById(subscriptionEntity.getPlan());
    subscription.setPlan(new Subscription.Plan(plan.getId(), plan.getName()));
    subscription.getPlan().setSecurity(plan.getSecurity());
    ApiEntity api = apiService.findById(subscriptionEntity.getApi());
    subscription.setApi(new Subscription.Api(api.getId(), api.getName(), api.getVersion(), new Subscription.User(api.getPrimaryOwner().getId(), api.getPrimaryOwner().getDisplayName())));
    subscription.setClosedAt(subscriptionEntity.getClosedAt());
    return subscription;
}
Also used : Subscription(io.gravitee.management.rest.model.Subscription)

Aggregations

Subscription (io.gravitee.management.rest.model.Subscription)5 ApplicationEntity (io.gravitee.management.model.ApplicationEntity)1 PlanEntity (io.gravitee.management.model.PlanEntity)1 Permissions (io.gravitee.management.rest.security.Permissions)1