部署集
更新时间:2024-07-02
查询部署集列表
如下代码可以查询用户的部署集列表:
import com.baidubce.BceClientConfiguration;
import com.baidubce.Protocol;
import com.baidubce.auth.DefaultBceCredentials;
import com.baidubce.services.bcc.BccClient;
import com.baidubce.services.bcc.BccClientConfiguration;
import com.baidubce.services.bcc.model.deployset.ListDeploySetResponse;
public class Main {
public static void main(String[] args) {
// 设置您的ak、sk和要访问的endpoint
String endpoint = "bcc.bj.baidubce.com";
String ak = "ak";
String sk = "sk";
// 设置默认配置
BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
.withProtocol(Protocol.HTTP)
.withCredentials(new DefaultBceCredentials(ak, sk))
.withEndpoint(endpoint);
// 创建bcc client
BccClient client = new BccClient(bccClientConfiguration);
// 请求查询部署集列表
ListDeploySetResponse deploySets = client.listDeploySet();
System.out.println(deploySets);
}
}
创建部署集
如下代码可以创建部署集:
import com.baidubce.BceClientConfiguration;
import com.baidubce.Protocol;
import com.baidubce.auth.DefaultBceCredentials;
import com.baidubce.services.bcc.BccClient;
import com.baidubce.services.bcc.BccClientConfiguration;
import com.baidubce.services.bcc.model.deployset.CreateDeploySetRequest;
import com.baidubce.services.bcc.model.deployset.CreateDeploySetResponse;
public class Main {
public static void main(String[] args) {
// 设置您的ak、sk和要访问的endpoint
String endpoint = "bcc.bj.baidubce.com";
String ak = "ak";
String sk = "sk";
// 设置默认配置
BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
.withProtocol(Protocol.HTTP)
.withCredentials(new DefaultBceCredentials(ak, sk))
.withEndpoint(endpoint);
// 创建bcc client
BccClient client = new BccClient(bccClientConfiguration);
// 请求创建部署集
CreateDeploySetRequest request = new CreateDeploySetRequest();
// 部署集名称
request.setName("your_deploy_set_name");
// 部署集描述
request.setDesc("your deploy set description");
// 部署集策略, 默认为HOST_HA
request.setStrategy("HOST_HA");
// 部署集并发数, 默认为1
request.setConcurrency(6);
CreateDeploySetResponse deploySet = client.createDeploySet(request);
System.out.println(deploySet);
}
}
删除部署集
如下代码可以删除部署集:
import com.baidubce.BceClientConfiguration;
import com.baidubce.Protocol;
import com.baidubce.auth.DefaultBceCredentials;
import com.baidubce.services.bcc.BccClient;
import com.baidubce.services.bcc.BccClientConfiguration;
import com.baidubce.services.bcc.model.deployset.DeleteDeploySetRequest;
public class Main {
public static void main(String[] args) {
// 设置您的ak、sk和要访问的endpoint
String endpoint = "bcc.bj.baidubce.com";
String ak = "ak";
String sk = "sk";
// 设置默认配置
BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
.withProtocol(Protocol.HTTP)
.withCredentials(new DefaultBceCredentials(ak, sk))
.withEndpoint(endpoint);
// 创建bcc client
BccClient client = new BccClient(bccClientConfiguration);
// 请求删除部署集
DeleteDeploySetRequest request = new DeleteDeploySetRequest();
// 部署集id
request.setDeployId("dset-***");
client.deleteDeploySet(request);
}
}
修改部署集
如下代码可以修改部署集属性:
import com.baidubce.BceClientConfiguration;
import com.baidubce.Protocol;
import com.baidubce.auth.DefaultBceCredentials;
import com.baidubce.services.bcc.BccClient;
import com.baidubce.services.bcc.BccClientConfiguration;
import com.baidubce.services.bcc.model.deployset.UpdateDeploySetRequest;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
// 设置您的ak、sk和要访问的endpoint
String endpoint = "bcc.bj.baidubce.com";
String ak = "ak";
String sk = "sk";
// 设置默认配置
BceClientConfiguration bccClientConfiguration = new BccClientConfiguration()
.withProtocol(Protocol.HTTP)
.withCredentials(new DefaultBceCredentials(ak, sk))
.withEndpoint(endpoint);
// 创建bcc client
BccClient client = new BccClient(bccClientConfiguration);
// 请求修改部署集属性
UpdateDeploySetRequest request = new UpdateDeploySetRequest();
// 部署集id
request.setDeployId("dset-***");
// 部署集名称
request.setName("modify_deploy_name");
// 部署集描述
request.setDesc("modify description");
client.updateDeploySet(request);
}
}