@@ -143,6 +143,7 @@ public class ApiConstants { | |||||
public static final String EP_DOMAINS = DOMAINS_ENDPOINT; | public static final String EP_DOMAINS = DOMAINS_ENDPOINT; | ||||
public static final String EP_NETWORKS = "/networks"; | public static final String EP_NETWORKS = "/networks"; | ||||
public static final String EP_PLANS = PLANS_ENDPOINT; | public static final String EP_PLANS = PLANS_ENDPOINT; | ||||
public static final String EP_CURRENT_PLANS = "/currentPlans"; | |||||
public static final String EP_TAGS = "/tags"; | public static final String EP_TAGS = "/tags"; | ||||
public static final String EP_NODES = "/nodes"; | public static final String EP_NODES = "/nodes"; | ||||
public static final String EP_DEVICES = "/devices"; | public static final String EP_DEVICES = "/devices"; | ||||
@@ -17,17 +17,14 @@ import bubble.model.account.message.ActionTarget; | |||||
import bubble.model.cloud.BubbleNetwork; | import bubble.model.cloud.BubbleNetwork; | ||||
import bubble.model.device.BubbleDeviceType; | import bubble.model.device.BubbleDeviceType; | ||||
import bubble.resources.app.AppsResource; | import bubble.resources.app.AppsResource; | ||||
import bubble.resources.bill.AccountPaymentMethodsResource; | |||||
import bubble.resources.bill.AccountPaymentsResource; | |||||
import bubble.resources.bill.AccountPlansResource; | |||||
import bubble.resources.bill.BillsResource; | |||||
import bubble.resources.bill.*; | |||||
import bubble.resources.cloud.*; | import bubble.resources.cloud.*; | ||||
import bubble.resources.driver.DriversResource; | import bubble.resources.driver.DriversResource; | ||||
import bubble.resources.notify.ReceivedNotificationsResource; | import bubble.resources.notify.ReceivedNotificationsResource; | ||||
import bubble.resources.notify.SentNotificationsResource; | import bubble.resources.notify.SentNotificationsResource; | ||||
import bubble.server.BubbleConfiguration; | import bubble.server.BubbleConfiguration; | ||||
import bubble.service.account.StandardAuthenticatorService; | |||||
import bubble.service.account.MitmControlService; | import bubble.service.account.MitmControlService; | ||||
import bubble.service.account.StandardAuthenticatorService; | |||||
import bubble.service.account.download.AccountDownloadService; | import bubble.service.account.download.AccountDownloadService; | ||||
import bubble.service.boot.SelfNodeService; | import bubble.service.boot.SelfNodeService; | ||||
import bubble.service.cloud.StandardNetworkService; | import bubble.service.cloud.StandardNetworkService; | ||||
@@ -536,12 +533,19 @@ public class AccountsResource { | |||||
} | } | ||||
@Path("/{id}"+EP_PLANS) | @Path("/{id}"+EP_PLANS) | ||||
public AccountPlansResource getPlans(@Context ContainerRequest ctx, | |||||
@PathParam("id") String id) { | |||||
public AccountPlansResource getAllPlans(@Context ContainerRequest ctx, | |||||
@PathParam("id") String id) { | |||||
final AccountContext c = new AccountContext(ctx, id); | final AccountContext c = new AccountContext(ctx, id); | ||||
return configuration.subResource(AccountPlansResource.class, c.account); | return configuration.subResource(AccountPlansResource.class, c.account); | ||||
} | } | ||||
@Path("/{id}"+EP_CURRENT_PLANS) | |||||
public CurrentAccountPlansResource getCurrentPlans(@Context ContainerRequest ctx, | |||||
@PathParam("id") String id) { | |||||
final AccountContext c = new AccountContext(ctx, id); | |||||
return configuration.subResource(CurrentAccountPlansResource.class, c.account); | |||||
} | |||||
@Path("/{id}"+EP_KEYS) | @Path("/{id}"+EP_KEYS) | ||||
public AccountSshKeysResource getSshKeys(@Context ContainerRequest ctx, | public AccountSshKeysResource getSshKeys(@Context ContainerRequest ctx, | ||||
@PathParam("id") String id) { | @PathParam("id") String id) { | ||||
@@ -17,10 +17,7 @@ import bubble.model.account.message.AccountMessageType; | |||||
import bubble.model.account.message.ActionTarget; | import bubble.model.account.message.ActionTarget; | ||||
import bubble.model.device.BubbleDeviceType; | import bubble.model.device.BubbleDeviceType; | ||||
import bubble.resources.app.AppsResource; | import bubble.resources.app.AppsResource; | ||||
import bubble.resources.bill.AccountPaymentMethodsResource; | |||||
import bubble.resources.bill.AccountPaymentsResource; | |||||
import bubble.resources.bill.AccountPlansResource; | |||||
import bubble.resources.bill.BillsResource; | |||||
import bubble.resources.bill.*; | |||||
import bubble.resources.cloud.*; | import bubble.resources.cloud.*; | ||||
import bubble.resources.driver.DriversResource; | import bubble.resources.driver.DriversResource; | ||||
import bubble.resources.notify.ReceivedNotificationsResource; | import bubble.resources.notify.ReceivedNotificationsResource; | ||||
@@ -300,11 +297,17 @@ public class MeResource { | |||||
} | } | ||||
@Path(EP_PLANS) | @Path(EP_PLANS) | ||||
public AccountPlansResource getPlans(@Context ContainerRequest ctx) { | |||||
public AccountPlansResource getAllPlans(@Context ContainerRequest ctx) { | |||||
final Account caller = userPrincipal(ctx); | final Account caller = userPrincipal(ctx); | ||||
return configuration.subResource(AccountPlansResource.class, caller); | return configuration.subResource(AccountPlansResource.class, caller); | ||||
} | } | ||||
@Path(EP_CURRENT_PLANS) | |||||
public CurrentAccountPlansResource getCurrentPlans(@Context ContainerRequest ctx) { | |||||
final Account caller = userPrincipal(ctx); | |||||
return configuration.subResource(CurrentAccountPlansResource.class, caller); | |||||
} | |||||
@Path(EP_KEYS) | @Path(EP_KEYS) | ||||
public AccountSshKeysResource getSshKeys(@Context ContainerRequest ctx) { | public AccountSshKeysResource getSshKeys(@Context ContainerRequest ctx) { | ||||
final Account caller = userPrincipal(ctx); | final Account caller = userPrincipal(ctx); | ||||
@@ -51,7 +51,7 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco | |||||
@Autowired private AccountSshKeyDAO sshKeyDAO; | @Autowired private AccountSshKeyDAO sshKeyDAO; | ||||
@Autowired private BubbleDomainDAO domainDAO; | @Autowired private BubbleDomainDAO domainDAO; | ||||
@Autowired private BubbleNetworkDAO networkDAO; | |||||
@Autowired protected BubbleNetworkDAO networkDAO; | |||||
@Autowired private BubblePlanDAO planDAO; | @Autowired private BubblePlanDAO planDAO; | ||||
@Autowired private BubbleFootprintDAO footprintDAO; | @Autowired private BubbleFootprintDAO footprintDAO; | ||||
@Autowired private CloudServiceDAO cloudDAO; | @Autowired private CloudServiceDAO cloudDAO; | ||||
@@ -62,19 +62,11 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco | |||||
public AccountPlansResource(Account account) { super(account); } | public AccountPlansResource(Account account) { super(account); } | ||||
@Override protected List<AccountPlan> list(ContainerRequest ctx) { | |||||
return getDao().findByAccountAndNotDeleted(account.getUuid()); | |||||
} | |||||
@Override protected AccountPlan find(ContainerRequest ctx, String id) { | |||||
return getDao().findByAccountAndIdAndNotDeleted(getAccountUuid(ctx), id); | |||||
} | |||||
@Override protected AccountPlan findAlternate(ContainerRequest ctx, String id) { | @Override protected AccountPlan findAlternate(ContainerRequest ctx, String id) { | ||||
// id might be a network uuid | // id might be a network uuid | ||||
final String accountUuid = getAccountUuid(ctx); | final String accountUuid = getAccountUuid(ctx); | ||||
final BubbleNetwork network = networkDAO.findByAccountAndId(accountUuid, id); | final BubbleNetwork network = networkDAO.findByAccountAndId(accountUuid, id); | ||||
return network == null ? null : getDao().findByAccountAndNetworkAndNotDeleted(accountUuid, network.getUuid()); | |||||
return network == null ? null : getDao().findByAccountAndNetwork(accountUuid, network.getUuid()); | |||||
} | } | ||||
@Override protected boolean canCreate(Request req, ContainerRequest ctx, Account caller, AccountPlan request) { | @Override protected boolean canCreate(Request req, ContainerRequest ctx, Account caller, AccountPlan request) { | ||||
@@ -0,0 +1,46 @@ | |||||
/** | |||||
* Copyright (c) 2020 Bubble, Inc. All rights reserved. | |||||
* For personal (non-commercial) use, see license: https://bubblev.com/bubble-license/ | |||||
*/ | |||||
package bubble.resources.bill; | |||||
import bubble.model.account.Account; | |||||
import bubble.model.bill.AccountPlan; | |||||
import bubble.model.cloud.BubbleNetwork; | |||||
import org.glassfish.grizzly.http.server.Request; | |||||
import org.glassfish.jersey.server.ContainerRequest; | |||||
import java.util.List; | |||||
public class CurrentAccountPlansResource extends AccountPlansResource { | |||||
public CurrentAccountPlansResource(Account account) { super(account); } | |||||
@Override protected List<AccountPlan> list(ContainerRequest ctx) { | |||||
return getDao().findByAccountAndNotDeleted(account.getUuid()); | |||||
} | |||||
@Override protected AccountPlan find(ContainerRequest ctx, String id) { | |||||
return getDao().findByAccountAndIdAndNotDeleted(getAccountUuid(ctx), id); | |||||
} | |||||
@Override protected AccountPlan findAlternate(ContainerRequest ctx, String id) { | |||||
// id might be a network uuid | |||||
final String accountUuid = getAccountUuid(ctx); | |||||
final BubbleNetwork network = networkDAO.findByAccountAndId(accountUuid, id); | |||||
return network == null ? null : getDao().findByAccountAndNetworkAndNotDeleted(accountUuid, network.getUuid()); | |||||
} | |||||
@Override protected boolean canCreate(Request req, ContainerRequest ctx, Account caller, AccountPlan request) { | |||||
return false; | |||||
} | |||||
@Override protected boolean canUpdate(ContainerRequest ctx, Account caller, AccountPlan found, AccountPlan request) { | |||||
return false; | |||||
} | |||||
@Override protected boolean canDelete(ContainerRequest ctx, Account caller, AccountPlan found) { | |||||
return false; | |||||
} | |||||
} |
@@ -224,8 +224,8 @@ | |||||
}, | }, | ||||
{ | { | ||||
"comment": "verify no plans exist", | |||||
"request": { "uri": "me/plans" }, | |||||
"comment": "verify no current plans exist", | |||||
"request": { "uri": "me/currentPlans" }, | |||||
"response": { | "response": { | ||||
"check": [ {"condition": "json.length === 0"} ] | "check": [ {"condition": "json.length === 0"} ] | ||||
} | } | ||||
@@ -1 +1 @@ | |||||
Subproject commit fce6adf44d1ea052deebf19ed6c964447c4af9b7 | |||||
Subproject commit d0617bbadd003f5b65f1d712b5a84aa527ee841d |