瀏覽代碼

add new endpoint to return current plans vs all plans

tags/v0.9.14
Jonathan Cobb 4 年之前
父節點
當前提交
26abdd551e
共有 7 個檔案被更改,包括 71 行新增25 行删除
  1. +1
    -0
      bubble-server/src/main/java/bubble/ApiConstants.java
  2. +11
    -7
      bubble-server/src/main/java/bubble/resources/account/AccountsResource.java
  3. +8
    -5
      bubble-server/src/main/java/bubble/resources/account/MeResource.java
  4. +2
    -10
      bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java
  5. +46
    -0
      bubble-server/src/main/java/bubble/resources/bill/CurrentAccountPlansResource.java
  6. +2
    -2
      bubble-server/src/test/resources/models/tests/payment/pay_credit_refund_and_restart.json
  7. +1
    -1
      bubble-web

+ 1
- 0
bubble-server/src/main/java/bubble/ApiConstants.java 查看文件

@@ -143,6 +143,7 @@ public class ApiConstants {
public static final String EP_DOMAINS = DOMAINS_ENDPOINT;
public static final String EP_NETWORKS = "/networks";
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_NODES = "/nodes";
public static final String EP_DEVICES = "/devices";


+ 11
- 7
bubble-server/src/main/java/bubble/resources/account/AccountsResource.java 查看文件

@@ -17,17 +17,14 @@ import bubble.model.account.message.ActionTarget;
import bubble.model.cloud.BubbleNetwork;
import bubble.model.device.BubbleDeviceType;
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.driver.DriversResource;
import bubble.resources.notify.ReceivedNotificationsResource;
import bubble.resources.notify.SentNotificationsResource;
import bubble.server.BubbleConfiguration;
import bubble.service.account.StandardAuthenticatorService;
import bubble.service.account.MitmControlService;
import bubble.service.account.StandardAuthenticatorService;
import bubble.service.account.download.AccountDownloadService;
import bubble.service.boot.SelfNodeService;
import bubble.service.cloud.StandardNetworkService;
@@ -536,12 +533,19 @@ public class AccountsResource {
}

@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);
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)
public AccountSshKeysResource getSshKeys(@Context ContainerRequest ctx,
@PathParam("id") String id) {


+ 8
- 5
bubble-server/src/main/java/bubble/resources/account/MeResource.java 查看文件

@@ -17,10 +17,7 @@ import bubble.model.account.message.AccountMessageType;
import bubble.model.account.message.ActionTarget;
import bubble.model.device.BubbleDeviceType;
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.driver.DriversResource;
import bubble.resources.notify.ReceivedNotificationsResource;
@@ -300,11 +297,17 @@ public class MeResource {
}

@Path(EP_PLANS)
public AccountPlansResource getPlans(@Context ContainerRequest ctx) {
public AccountPlansResource getAllPlans(@Context ContainerRequest ctx) {
final Account caller = userPrincipal(ctx);
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)
public AccountSshKeysResource getSshKeys(@Context ContainerRequest ctx) {
final Account caller = userPrincipal(ctx);


+ 2
- 10
bubble-server/src/main/java/bubble/resources/bill/AccountPlansResource.java 查看文件

@@ -51,7 +51,7 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco

@Autowired private AccountSshKeyDAO sshKeyDAO;
@Autowired private BubbleDomainDAO domainDAO;
@Autowired private BubbleNetworkDAO networkDAO;
@Autowired protected BubbleNetworkDAO networkDAO;
@Autowired private BubblePlanDAO planDAO;
@Autowired private BubbleFootprintDAO footprintDAO;
@Autowired private CloudServiceDAO cloudDAO;
@@ -62,19 +62,11 @@ public class AccountPlansResource extends AccountOwnedResource<AccountPlan, Acco

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) {
// 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());
return network == null ? null : getDao().findByAccountAndNetwork(accountUuid, network.getUuid());
}

@Override protected boolean canCreate(Request req, ContainerRequest ctx, Account caller, AccountPlan request) {


+ 46
- 0
bubble-server/src/main/java/bubble/resources/bill/CurrentAccountPlansResource.java 查看文件

@@ -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;
}

}

+ 2
- 2
bubble-server/src/test/resources/models/tests/payment/pay_credit_refund_and_restart.json 查看文件

@@ -224,8 +224,8 @@
},

{
"comment": "verify no plans exist",
"request": { "uri": "me/plans" },
"comment": "verify no current plans exist",
"request": { "uri": "me/currentPlans" },
"response": {
"check": [ {"condition": "json.length === 0"} ]
}


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit fce6adf44d1ea052deebf19ed6c964447c4af9b7
Subproject commit d0617bbadd003f5b65f1d712b5a84aa527ee841d

Loading…
取消
儲存